According to this, do following to determine the client ipaddress:
1 | var ip = (req.headers['x-forwarded-for'] || |
According to this, do following to determine the client ipaddress:
1 | var ip = (req.headers['x-forwarded-for'] || |
According to mongoose.js doc, it is able to set setters to a field on schema.
However, the doc is not quite detailed and obselete.
Some example:1
2
3
4
5
6
7
8
9
10
11var schema=new Schema({
password:{
type:String,
required:true,
set:hash
}
})
function hash(plainPwd){
return require("crypto").createHash("sha1").update(plainPwd).update(secret).digest("hex");
}
minimist is a lightweight cli argument (command line arguments) parser:
1 | require('minimist')("-x 3 -y 4 -n5 -abc --beep=boop foo bar baz"); |