Skip to content

Instantly share code, notes, and snippets.

@lymanlai
Created September 28, 2013 18:55
Show Gist options
  • Save lymanlai/6745216 to your computer and use it in GitHub Desktop.
Save lymanlai/6745216 to your computer and use it in GitHub Desktop.
async
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