@@ -8,15 +8,15 @@ exports.index = function(req, res) {<% if (!filters.mongoose) { %>
88 res . json ( [ ] ) ; < % } % > < % if ( filters . mongoose ) { % >
99 < %= classedName % > .find(function (err, < %= name % > s) {
1010 if ( err ) { return handleError ( res , err ) ; }
11- return res . json ( 200 , < %= name % > s);
11+ return res . status ( 200 ) . json ( < %= name % > s);
1212 } ) ; < % } % >
1313} ; < % if ( filters . mongoose ) { % >
1414
1515// Get a single < %= name % >
1616exports.show = function(req, res) {
1717 < %= classedName % > .findById(req.params.id, function (err, < %= name % > ) {
1818 if ( err ) { return handleError ( res , err ) ; }
19- if ( ! < %= name % > ) { return res . send ( 404 ) ; }
19+ if ( ! < %= name % > ) { return res . status ( 404 ) . send ( 'Not Found' ) ; }
2020 return res.json(< %= name % > );
2121 } ) ;
2222} ;
@@ -25,7 +25,7 @@ exports.show = function(req, res) {
2525exports . create = function ( req , res ) {
2626 < %= classedName % > .create(req.body, function(err, < %= name % > ) {
2727 if ( err ) { return handleError ( res , err ) ; }
28- return res . json ( 201 , < %= name % > );
28+ return res . status ( 201 ) . json ( < %= name % > );
2929 } ) ;
3030} ;
3131
@@ -34,11 +34,11 @@ exports.update = function(req, res) {
3434 if ( req . body . _id ) { delete req . body . _id ; }
3535 < %= classedName % > .findById(req.params.id, function (err, < %= name % > ) {
3636 if ( err ) { return handleError ( res , err ) ; }
37- if ( ! < %= name % > ) { return res . send ( 404 ) ; }
37+ if ( ! < %= name % > ) { return res . status ( 404 ) . send ( 'Not Found' ) ; }
3838 var updated = _.merge(< %= name % > , req.body);
3939 updated.save(function (err) {
4040 if ( err ) { return handleError ( res , err ) ; }
41- return res . json ( 200 , < %= name % > );
41+ return res . status ( 200 ) . json ( < %= name % > );
4242 } ) ;
4343 } );
4444} ;
@@ -47,14 +47,14 @@ exports.update = function(req, res) {
4747exports . destroy = function ( req , res ) {
4848 < %= classedName % > .findById(req.params.id, function (err, < %= name % > ) {
4949 if ( err ) { return handleError ( res , err ) ; }
50- if ( ! < %= name % > ) { return res . send ( 404 ) ; }
50+ if ( ! < %= name % > ) { return res . status ( 404 ) . send ( 'Not Found' ) ; }
5151 < %= name % > .remove(function(err) {
5252 if ( err ) { return handleError ( res , err ) ; }
53- return res . send ( 204 ) ;
53+ return res . status ( 204 ) . send ( 'No Content' ) ;
5454 } );
5555 } ) ;
5656} ;
5757
5858function handleError ( res , err ) {
59- return res . send ( 500 , err ) ;
59+ return res . status ( 500 ) . send ( err ) ;
6060} < % } % >
0 commit comments