Skip to content

Instantly share code, notes, and snippets.

@jinto
Created March 16, 2012 14:49
Show Gist options
  • Select an option

  • Save jinto/2050391 to your computer and use it in GitHub Desktop.

Select an option

Save jinto/2050391 to your computer and use it in GitHub Desktop.
functional express handler
express.post('/api/create-post-head', auth.filter.login(), function (req, res, next) {
prepareRoleAndForm(req, function (role, form) {
checkCategoryWritable(res, role, form.categoryId, function (category) {
checkFormThreadAndPost(res, form, function () {
insertThread(form, function (err, thread) {
if (err) return next(err);
insertPost(req, form, thread, function (err, post) {
if (err) return next(err);
res.json(200, {threadId: thread._id, postId: post._id});
});
});
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment