Giter Site home page Giter Site logo

gympass-node-api's Introduction

Gympass Node API

Node.js Fastify Prisma Vitest supertest bcryptjs dayjs Zod eslint dotenv PostgreSQL Docker pnpm

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.

Getting Started

  1. Clone this repo:
$ git clone https://github.com/DaniloNR/gympass-node-api.git
  1. Then go to the project's folder:
cd gympass-node-api
  1. Before running anything, make sure you are using node v20
nvm use 20
  1. Install all dependencies:
pnpm install
  1. 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
  1. Run migrations:
pnpm migrate
  1. Generate prisma types:
pnpm generate:types
  1. Run locally:
pnpm start:dev

Workflows

There are two workflows configured on this repository for running tests

  • E2E Testing: .github/workflows/e2e-testing.yml triggers on any pull_request
  • Unit Testing: .github/workflows/unit-testing.yml triggers on any push

Dependabot

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.

SOLID Principles

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

Testing

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

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

Functional Requirements

  • 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;

Business Rules

  • 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;

Non-functional Requirements

  • 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);

License

MIT License © Danilo Nogueira

Open Source

Feel free to clone this repo and use the way you want it!

gympass-node-api's People

Contributors

danilonr avatar dependabot[bot] avatar

Stargazers

Diego Fontenelle avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.