Boss Machine & Bonus Solutions

Hi! Finished the boss machine project. It was overall pretty straightforward but the bonus section had some non-descriptive test errors that I ended up spending a lot of time on. Turns out I forgot to return out of an Array.filter() without implicit return. Big facepalm moment after spending an hour trying to get it to work.

3 things I did that I’d recommend:

  • Use Router.param() wherever possible to simplify. I may have missed a couple of req.param.{var} statements but overall using the param method is very easy. Most importantly, it lets you do a lot of validation upfront so you can keep your route code clean and straightforward.
  • Router.route() with .get, .post(), .put(), and .delete() calls underneath. This seems to be the canonical way to write express and it simplified things greatly.
  • Breaking out routers with app.use(). I’m pretty sure this is how they wanted us to do it so I’m glad i remembered. I considered breaking out another router with the bonus but decided that since there were so few lines, I’d include those in the minions router.

If you have any questions, concerns, or need help with your own project. Please respond!

You can see all my work in the gist here: Off-Platform Project: Boss Machine · GitHub