Skip to content

Solid API developed in Module 2 of the Rocketseat Ignite Node.js track. Introducing SOLID principles, Design Patterns, Docker for database initialization, JWT, Refresh Token, RBAC, CI/CD and various other concepts. Utilizing Prisma, TypeScript, Vitest, Fastify, and Zod.

Notifications You must be signed in to change notification settings

joaohenriquefernandes/api-solid

Repository files navigation

API Rest - API SOLID

Check Ins Api developed on Rocketseat Node Ignite trail

💻 | Technology

Node.js TypeScript Fastify Docker PostgreSQL Prisma Vitest ESlint Git

👨‍💻 | Running Project

Clone this repository

  git clone https://github.com/joaohenriquefernandes/api-solid.git
  cd api-solid

Dependency installs

  npm install

Creating the containers from the docker-compose file

  docker-compose up -d

Running migrations

  npx prisma migrate:dev

Starting project

  npm run dev

📍 | Routes

Method Route Description
POST /gyms/:gymId/check-ins Create a new check in
PATCH /check-ins/:checkInId/validate Validate a check in
GET /check-ins/history Get the check in history
GET /check-ins/metrics Get the check in metrics
POST /gyms Create a new gym
GET /gyms/search Search gyms
GET /gyms/nearby Get nearby gyms
POST /register Create a new user
POST /sessions Authenticate a user
PATCH /token/refresh Create a refresh token
GET /me Get the user profile

🟣 | Project Insomnia

Run in Insomnia}

🧪 | Automated Unit Tests

  • Should be able to authenticate
  • Should not be able to authenticate with wrong email
  • Should not be able to authenticate with wrong password
  • Should be able to check in
  • Should not be able to check in twice in same day
  • Should be able to check in twice in different day
  • Should not be able to check in on distance gym
  • Should be able to create gym
  • Should be able to fetch nearby gyms
  • Should be able to fetch check ins history
  • Should be able to fetch paginated user check in history
  • Should be able to get check-ins count from metrics
  • Should be able to get user profile
  • Should not be able to get user profile with wrong id
  • Should be able to register
  • Should hash user password upon registration
  • Should not be able to resgister with same email twice
  • Should be able to search for gyms
  • Should be able to fetch paginated gyms search
  • Should be able to validate the check-in
  • Should not be able to validate an inexistent check-in
  • Should not be able to validate the check-in after 20 minutes of this creation

Running unit tests

  npm test

🧪 | Automated End-to-End Tests

  • Should be able to create check in
  • Should be able to list history check ins
  • Should be able to get mestrics check ins
  • Should be able to validate a check in

Running e2e tests

  npm test:e2e

Functional Requirements (FRs)

  • Users must be able to register.
  • Users must be able to authenticate.
  • Users must be able to retrieve the profile of a logged-in user.
  • Users must be able to retrieve the number of check-ins performed by the logged-in user.
  • Users must be able to retrieve their check-in history.
  • Users must be able to search for nearby gyms.
  • Users must be able to search for gyms by name.
  • Users must be able to check-in at a gym.
  • Users must be able to validate their check-in.
  • Gyms must be able to register.

Business Rules (BRs)

  • Users cannot register with duplicate emails.
  • Users cannot perform 2 check-ins on the same day.
  • Users cannot check-in if they are not close (within 100m) to the gym.
  • Check-ins can only be validated up to 20 minutes after creation.
  • Check-ins can only be validated by administrators.
  • Gyms can only be registered by administrators.

Non-functional Requirements (NFRs)

  • User passwords must be encrypted.
  • Application data must be persisted in a PostgreSQL database.
  • All data lists must be paginated with 20 items per page.
  • Users must be identified by a JSON Web Token (JWT).

About

Solid API developed in Module 2 of the Rocketseat Ignite Node.js track. Introducing SOLID principles, Design Patterns, Docker for database initialization, JWT, Refresh Token, RBAC, CI/CD and various other concepts. Utilizing Prisma, TypeScript, Vitest, Fastify, and Zod.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published