Permalink
Browse files

Added notfound middleware to example

  • Loading branch information...
1 parent e310bc0 commit a62eafcad9989eebc3604020e14603281d57fb48 @scttnlsn committed Sep 21, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 example/notes.js
View
11 example/notes.js
@@ -27,6 +27,14 @@ notes.get('/',
}
);
+var notfound = function(req, res, next) {
+ if (!req.instance) {
+ res.json({ error: 'Note not found' }, 404);
+ } else {
+ next();
+ }
+};
+
notes.post('/',
emt.crud.create(),
emt.crud.save(),
@@ -35,18 +43,21 @@ notes.post('/',
notes.get('/:id',
emt.crud.load(),
+ notfound,
emt.json.show()
);
notes.put('/:id',
emt.crud.load(),
+ notfound,
emt.crud.update(),
emt.crud.save(),
emt.json.show()
);
notes.del('/:id',
emt.crud.load(),
+ notfound,
emt.crud.remove(),
emt.json.show({ status: 204 })
);

0 comments on commit a62eafc

Please sign in to comment.