Back-end part of the e-commerce website selling tennis products. REST API is implemented according to the Entity-Relationship Diagram outlining the data model including the relationships and attributes of collections within the system.
- Clone the project
git clone https://github.com/sytnikov/tennis-store-backend.git; - Create your
.envfile using.env.examplefile as an exaple and fill it with your credentials; - Use
npm installto install all dependencies and necessary packages; - Run the server using
npm run sever.
Within the project, the following entities are covered: users, products, categories, orders, and roles.

Based on the specifications provided in the ERD assignment the basic CRUD (Create, Read, Update, Delete) operations for the entities are implemented.
For security resons, certain endpoint are protected with the following middleware:
- checkAuth: verifying is a user is logged in. There are two ways of authentication implemented: using JWT and brokered authentication with Google;
- checkRole: verifying if a user is a customer or and admin;
- checkPermissions: verifying if an admin has a particular access
All API responses are provided in JSON format which includes a status, data, and an optional message field.
To handle API errors, the apiErrorHandler is implemented.
Below is the high-level project folder structure represented.
.
├── server
| ├── controllers
| ├── middlewares
| ├── models
| ├── routes
| ├── schemas
| ├── services
| ├── test
| ├── types
| ├── utils
| ├── app.ts
| ├── server.ts
├── .env.example
├── .gitignore
├── package.json
├── Database-ER-diagram.png
├── README.md
├── jest.config.ts
└── tsconfig.json
The test cases for all the key Services and Controllers have been built with Jest testing library. In this porject, unit testing and integration testing approaches were used. The test requests are sent to the built mock server, not the real API.
Run npm run test to implement all the tests.
The back-end part is deployed using the Render service here (produts route example): https://tennis-store-backend.onrender.com/products