chicken-sloths / bangazon-api-sprint1

API for a mock Amazon + Etsy platform providing developers access to the company's employee & product data
0 stars 0 forks source link

Set-up app.js for receiving routes, handling errors #86

Closed DavidLarsKetch closed 6 years ago

DavidLarsKetch commented 6 years ago

Context

  1. app.js receives all routes from routes/index.js & prepends the URL path to whatever we specify
  2. app.js catches all errors thrown in controllers and sends back 404 errors

Associated Product Ticket

Process

  1. Without this, routes will/may not run properly since app.js is, you know, the app
  2. Without error handling, we will be terrible programmers. Here's a non-exhaustive list of errors to handle:
    • 404: request made does not exist
    • 500: the app/database broke
  3. All controllers should call next(err) when an Error is thrown

Expected Result

Starting up the app (node app.js) & navigating to a completed MVC route in the browser, should return the requested data. Navigating to an incomplete MVC route or nonexistent route should return the appropriate error.