Skip to content
Myr

improve before hook in mvc example

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent 3db6dd7 · Browse files · 6 files+25 added−24 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

6 files+25 added−24 removed

  • tests:+7 added−0 removed
  • other:+18 added−24 removed

6 files+25 added−24 removed

modified:examples/mvc/controllers/pet/index.js+1 added-1 removed
modified:examples/mvc/controllers/user/index.js+1 added-1 removed
modified:examples/mvc/controllers/user-pet/index.js+1 added-1 removed
modified:examples/mvc/lib/boot.js+14 added-13 removed
modified:examples/mvc/index.js+1 added-8 removed
71 unmodified lines
7273// load controllers74require('./lib/boot')(app, { verbose: !module.parent });7576// assume "not found" in the error msgs77// is a 404. this is somewhat silly, but78// valid, you can do whatever you like, set79// properties, use instanceof etc.76app.use(function(err, req, res, next){81 // treat as 40482 if (~err.message.indexOf('not found')) return next();8377 // log it85 console.error(err.stack);78 if (!module.parent) console.error(err.stack);7980 // error page81 res.status(500).render('5xx');82});
11 unmodified lines
modified:test/acceptance/mvc.js+7 added
90 unmodified lines
91 })92 })9394 describe('PUT /user/:id', function(){95 it('should 500 on error', function(done){96 request(app)97 .put('/user/1')98 .send({})99 .expect(500, done)100 })101102 it('should update the user', function(done){103 request(app)104 .put('/user/1')105 .send({ user: { name: 'Tobo' }})
24 unmodified lines