gympass-node-api is a Node.js API designed to manage users' gym memberships across multiple gyms. It is built entirely in TypeScript and utilizes SOLID principles on its implementation.
- Clone this repo:
$ git clone https://github.com/DaniloNR/gympass-node-api.git
- Then go to the project's folder:
cd gympass-node-api
- Before running anything, make sure you are using node v20
nvm use 20
- Install all dependencies:
pnpm install
- Start the docker container for the database:
docker compose up -d
Note: -d refers to "detach" so the process will keep running even if the terminal is closed.
If you want to stop the container just run:
docker compose stop
- Run migrations:
pnpm migrate
- Generate prisma types:
pnpm generate:types
- Run locally:
pnpm start:dev
There are two workflows configured on this repository for running tests
- E2E Testing:
.github/workflows/e2e-testing.yml
triggers on anypull_request
- Unit Testing:
.github/workflows/unit-testing.yml
triggers on anypush
There is a additional workflow configured on this repository, the dependabot.
A .npmrc is setup containing a rule to prevent any package from being updated
when running a > pnpm install
, instead, the updates are performed by dependabot
on GitHub through pull requests weekly. If the tests pipelines pass, you can merge
to update the dependencies.
The project is built using the SOLID principles, which are:
- Single Responsibility Principle
- Open/Closed Principle
- Liskov Substitution Principle
- Interface Segregation Principle
- Dependency Inversion Principle
All you need to test the application is to run the scrips on package.json
Unit tests:
pnpm test
E2E tests:
pnpm test:e2e
if you want to run on watch mode, just add :watch
on the script and run.
Vitest-environments is utilized for handling end-to-end tests by creating a new schema on PostgreSQL before the test runs and destroying it after.
The environment configuration can be found on vitest-environments/prisma.ts
- User registration must be possible;
- User authentication must be possible;
- It must be possible to retrieve the profile of a logged-in user;
- It must be possible to retrieve the number of check-ins performed by the logged-in user;
- It must be possible for the user to retrieve their check-in history;
- It must be possible for the user to search for nearby gyms up to 10km;
- It must be possible for the user to search for gyms by name;
- It must be possible for the user to check-in at a gym;
- User check-in must be validated;
- It must be possible to register a gym;
- The user must not be able to register with a duplicate email;
- The user cannot make 2 check-ins on the same day;
- The user cannot check-in if not near (100m) the gym;
- Check-in can only be validated up to 20 minutes after it is created;
- Check-in can only be validated by administrators;
- The gym can only be registered by administrators;
- User password needs to be encrypted;
- Application data needs to be persisted in a PostgreSQL database;
- All data lists need to be paginated with 20 items per page;
- User must be identified by a JWT (JSON Web Token);
MIT License © Danilo Nogueira
Feel free to clone this repo and use the way you want it!