![logo](https://user-images.githubusercontent.com/92755273/190659291-ac953a00-e0a6-41ac-b2f6-bd6a559c0728.png)
Gym management web application that allows you to support clients accounts, gym passes and gym classes live schedule. Track upcoming events, calculate your BMI, check your membership status and prolong your gym pass.
This is the backend part of the project with REST API. To see the frontend part visit: https://github.com/RafalG1991/gym-system-manager-fe
To run this project make sure you have created .env file for db credentials: .env structure and configured the mysql database with this structure
GYM System Manager live preview
- React with TypeScript
- react-testing-library for components tests
- Cypress for e2e tests
- Node.js
- Express.js with TypeScript
- MySQL database (MariaDB)
- passport with JWT authentication
- Jest for unit tests
In this project, for backend, I used Node.js with Express framework. For authentication and authorization support I used passport middleware with JSON Web Token and custom passport strategy.
The project uses TypeScript and frontend-backend shared types. For data storage it uses MySQL database (MariaDB).
User and class records are handled using Active Record pattern. Each class provides basic validation and set of methods to add or modify entities in the database.
Routing is divided into two routes - user and class related. Most of the user routes are available only after authorization using verifyUser middleware.
Sign up route that checks for unique e-mail, adds new user to the database and returns httpOnly Cookie with user jwt token payload
Accepting JSON:
{
"email": string,
"password": string
}
Sign in route that verify user data and bcrypt hashed password and returns httpOnly Cookie with user jwt token payload
Accepting JSON:
{
"email": string,
"password": string
}
Endpoint for checking the authentication status. Returns user payload extracted from cookie, otherwise returns error message which is handled by frontend
Returns user data for the frontend
Changing user data route that handles name, bmi and password updating. Can handle three different data sets: firstname and lastname, password or height and weight as in the following example:
Accepting JSON:
{
"firstname": string,
"lastname": string
}
OR
{
"password": string
}
OR
{
"height": string,
"weight": string
}
Endpoint for extending membership status by the number of months provided in the body
Accepting JSON:
{
"months": number
}
Class routes are intentionally available without any kind of authorization. It can be used in the future for gym classes schedule on the home page
Returns all classes in json format with structure that is handled by react fullcalendar component
Returns single class by id passed in param
The project was supplied with Jest tests for class record and user record validation
In the project directory, you can run:
Runs the app in ts-node
Runs the app in development mode
Launches the test runner
Builds the app for production to the build
folder.