Implementing the Product API

The Product API will require all the knowledge that we acquired about Mongoose, ExpressJS routes, and RESTful APIs.

Our generator has already generated a good starter code for the Product API. So, we just need to tweak some variables to make it work with our new product model.

Testing the API

The final goal of the tests is to ensure that our API replies with the right status code and responses to different scenarios. We are going to test the following scenarios:

Product API: GET /api/products ✓ should respond with JSON array POST /api/products ✓ should respond with the newly created product GET /api/products/:id ✓ should respond with the requested product PUT /api/products/:id ✓ should respond with the updated product ...

Get Web Application Development with MEAN now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.