Created
September 28, 2013 18:55
-
-
Save lymanlai/6745216 to your computer and use it in GitHub Desktop.
async
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async.waterfall([ | |
getDbHandle, | |
function(args, cb){ | |
connection = args.connection; | |
args = { | |
connection: connection, | |
email: req.body.email | |
}; | |
cb(null, args); | |
}, | |
User.isEmailExist, | |
function validateInput (cb) { | |
var check = require('validator').check; | |
try { | |
check(req.body.email, 'email_invalid').isEmail(); | |
var args = { | |
connection: connection, | |
email: req.body.email, | |
displayName: req.body.displayName, | |
password: req.body.password | |
}; | |
cb(null, args); | |
} catch (e) { | |
cb(e.message); | |
} | |
}, | |
User.add | |
], function (status) { | |
res.send({status:status}); | |
releaseDbHandle(connection); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment