Video Rental Store RESTful Backend (NodeJS, MongoDB, Jest, TDD)
24 Sep 2020In this project, I used Express to implement a RESTful API for a video rental store backend. I employed TDD using Jest (a wrapper around Jasmine). I also manually tested the endpoints using Postman while developing and for testing the JWT.
Features:
- Input validation
- Middleware - for handling errors (a clean way to set up a try/catch block around the functionality of all of the API calls)
- Configuration section - for storing the private key for the JWT (JSON Web Token), which just ended up referencing an environment variable
- Debugging - Used winston for logging at different levels.
- Database Integration - I used Mongoose to interface with mongoDB to perform the necessary CRUD operations.
- Authentication - bcrypt for hashing passwords. Issues a JWT that some of the API endpoints require to return data.
Here is an example of Jest tests running and giving you a sense of the API.