Web service for adding and spending rewards points in user account.
This project was created as an exercise to practice Test-Driven Development (TDD) and to review foundational concepts of a REST API. I took the opportunity to set this project up from scratch in order to learn more about the role of Express in backend development. It was also the first time I assembled documentation using Swagger as I needed an interface to present my API.
- Node.js - v14.17.0
- Express - v4.17.2
- SQLite3 - v5.0.2
- Sequelize - v6.15.0
- Jest - v27.4.7
Notes:
I picked SQLite as the database for this project because I found out about in-memory databases only recently and I wanted to try using one. SQLite is prototype friendly and easy to set up. However, SQLite doesn't seem to be deployment friendly.
- Transactions can be added for points
- Points can be spent
- Get remaining points balance
MG Rewards API - Watch Video
- You will need
nodeandnpminstalled globally on your machine. - Git fork this repository into your desired directory. [forking guide]
npm installnpm start- Open
http://localhost:3000/api-docs/#/in your browser to access api docs. - Nodemon will watch for any changes in the files
npm test- Jest will watch for any changes in the files
- Make sure your Node version is at least version 14.
- Please note swagger-jsdoc is using v6.0.0 in this project. Other versions are not guaranteed to work.
-
missing validation and error handling inside routes
-
could have better error handling endware for routes
-
more thorough tests that handle edge cases and invalid inputs
-
better interfacing between route and resources
e.g rename /api/transactions/{payer} ---> /api/transactions/add
- research best practices for REST Architecture
- research some ways to deploy projects with SQLite
Tutorials used for this project: