API Project: Boss Machine full solution (inclues bonus)

This took me a while, but I proudly got through it. I chose to go a route of modularized routers and the parameters function (which paid off when doing the bonus work) in an aim to keep my work DRY. My biggest challenge was in debugging. I hadn’t had to use the VS debugger yet, so it took me some time to figure out that I could and should use that for figuring out errors. Once I completed one of the routers the rest of the work was relatively simple (changing the variables then testing). Overall, I found this to be a helpful exercise in understanding constructing routers and debugging using the console and the debugger.

1 Like

Just thought I share this (I’m pretty proud of it!):

[email protected] test
cross-env PORT=8000 mocha --watch

/api/minions routes
GET /api/minions
√ returns an array (44ms)
√ returns an array of all minions
GET /minions/:minionId
√ returns a single minion object
√ returns a full minion object
√ returned minion has the correct id
√ called with a non-numeric ID returns a 404 error
√ called with an invalid ID returns a 404 error
PUT /api/minions/:minionId
√ updates the correct minion and returns it
√ updates the correct minion and persists to the database
√ called with a non-numeric ID returns a 404 error
√ called with an invalid ID returns a 404 error
√ called with an invalid ID does not change the database array
POST /api/minions
√ should add a new minion if all supplied information is correct
DELETE /api/minions
√ deletes the correct minion by id
√ called with a non-numeric ID returns a 404 error
√ called with an invalid ID returns a 404 error

/api/ideas routes
GET /api/ideas
√ returns an array
√ returns an array of all ideas
GET /ideas/:ideaId
√ returns a single idea object
√ returns a full idea object with correct properties
√ returned idea has the correct id
√ called with a non-numeric ID returns a 404 error
√ called with an invalid ID returns a 404 error
PUT /api/ideas/:ideaId
√ updates the correct idea and returns it
√ updates the correct idea and persists to the database
√ called with a non-numeric ID returns a 404 error
√ called with an invalid ID returns a 404 error
√ called with an invalid ID does not change the database array
POST /api/ideas
√ should add a new idea if all supplied information is correct
DELETE /api/ideas
√ deletes the correct minion by id
√ called with a non-numeric ID returns a 404 error
√ called with an invalid ID returns a 404 error

checkMillionDollarIdea middleware
√ is a function takes three arguments
√ sends a 400 error if the total yield is less than one million dollars
√ calls next for ideas that will yield at least one million dollars
√ sends a 400 error if numWeeks or weeklyRevenue is not supplied
√ sends a 400 error if numWeeks or weeklyRevenue is an invalid string
√ is used in a POST /api/ideas route to reject insufficiently profitable ideas

/api/meetings routes
GET /api/meetings
√ returns an array
√ returns an array of all meetings
POST /api/meetings
√ should create a new meetings and return it
√ should persist the created meeting to the database
DELETE /api/meetings route
√ deletes all meetings

BONUS: /api/minions/:minionId/work routes
GET /api/minions/:minionId/work
√ returns an array
√ returns an array of all all work for the specified minion
√ called with a non-numeric minion ID returns a 404 error
√ called with an invalid ID minion returns a 404 error
PUT /api/minions/:minionId/work/:workId
√ updates the correct work and returns it
√ updates the correct work item and persists to the database
√ called with a non-numeric minion ID returns a 404 error
√ called with an invalid minion ID returns a 404 error
√ called with a non-numeric work ID returns a 404 error
√ called with an invalid work ID returns a 404 error
√ called with an invalid ID does not change the database array
√ returns a 400 if a work ID with the wrong :minionId is requested
POST /api/minions/:minionId/work
√ should add a new work item if all supplied information is correct
DELETE /api/minions/:minionId/work/:workId
√ deletes the correct work by id
√ called with a non-numeric minion ID returns a 404 error
√ called with an invalid minion ID returns a 404 error
√ called with a non-numeric work ID returns a 404 error
√ called with an invalid work ID returns a 404 error

61 passing (438ms)