Skip to content

Instantly share code, notes, and snippets.

@laser
Created May 14, 2015 17:16
Show Gist options
  • Save laser/f53d15c274a7a247fff3 to your computer and use it in GitHub Desktop.
Save laser/f53d15c274a7a247fff3 to your computer and use it in GitHub Desktop.
function create(req, res, next) {
Placement.create(req.body, function (err, placement) {
if (err) {
if (err instanceof RecordNotFound) {
res.status(status(404)).send();
}
else if (err instanceof ValidationFailed) {
res.status(status(400)).send();
}
else {
// internal error
res.status(status(500)).send();
}
}
else {
res
.status(status['Created'])
.json(placement);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment