Conversation
…ellows/lec-07 Lec 07
| @@ -0,0 +1,91 @@ | |||
| #Express API | |||
| @@ -0,0 +1,23 @@ | |||
| 'use strict'; | |||
There was a problem hiding this comment.
@meeksfred Update this as needed - we are totally cool with you modifying this file to conform to your own workflow and any helpers that you may need. This will become more relevant as we move into database integration - but yeah, this file is to help you - so make it your own when you get the chance.
| debug('user error'); | ||
| res.status(err.status).send(err.name); | ||
| next(); | ||
| return; |
There was a problem hiding this comment.
@meeksfred good use of a return to exit out of this - additionally, great use of next() to invoke the next function in the callback chain
| return fs.unlinkProm(`${__dirname}/../data/${schemaName}/${id}.json`) | ||
| .then() | ||
| .catch( err => Promise.reject(createError(404, err.message))); | ||
| }; |
There was a problem hiding this comment.
@meeksfred although most of this was done in class - the storage module looks good!
| if(!sauce) throw createError(400, 'expected sauce'); | ||
| if(!crust) throw createError(400, 'expected crust'); | ||
| if(!meat) throw createError(400, 'expected meat'); | ||
| if(!cheese) throw createError(400, 'expected cheese'); |
|
|
||
| app.listen(PORT, function(){ | ||
| debug(`server up ${PORT}`); | ||
| }); |
|
|
||
| require('../server.js'); | ||
|
|
||
| var pizza = { |
| .send(pizza) | ||
| .end((err, res) => { | ||
| if(err) return done(err); | ||
| tempPizza = res.body; |
There was a problem hiding this comment.
@meeksfred any reason for this assignment?
| describe('testing bad request', function(){ | ||
|
|
||
| before( done => { | ||
| pizza.meat = ''; |
| describe('testing valid route', function(){ | ||
| var tempPizza; | ||
|
|
||
| before( done => { |
There was a problem hiding this comment.
@meeksfred good before and after blocks
No description provided.