Git Product home page Git Product logo

gym-pass-api's Introduction

Gym Pass API

README file under construction

An open-source API for managing gyms and users. Project developed inside the Rocketseat Ignite program.

Author

Gabriel Rozzetti

Technologies

  • Node.js
  • Fastify
  • Fastify adapters:
    • JWT integration (@fastify/jwt)
    • Cookies (@fastify/cookies)
  • Zod (schema validation)
  • Prisma (ORM)
  • Postgres
  • Docker and Docker Compose
  • Bcrypt (for password hashing)
  • DayJS (for date manipulation)
  • Vitest (for unit tests and e2e tests)
  • Supertest (for e2e tests - mock requests)

Install

  • Node.js version: 18.16.0
  cd gym-pass
  npm i

Setup Docker Postgres

  docker compose up --build -d

Setup Environment Variables

Create a .env file in the root folder and copy the variables from the .env.example file.

Complete the DATABASE_URL with username, password, Postgres PORT (default: 5432) and database name.

NODE_ENV accepted options: dev | test | production

Fill the other variables also.

Setup Prisma

  # run migrations first
  npx prisma migrate dev

  # check if DB is ok
  npx prisma studio

Running

  # development mode  
  npm run start:dev

  # build and run
  npm run build
  npm start

Running Tests

Unit tests

  npm run test

  # watch mode
  npm run test:watch

  # coverage
  npm run test:coverage

E2E tests

  # run first to create the prisma test environment
  npm run test:e2e

  # watch mode
  npm run test:e2e:watch

API Docs

Users

Register a user

POST /api/users

Authenticate

POST /api/sessions

Refresh the token

PATCH /api/token/refresh

Get logged user profile

GET /api/me

Gym

Create a gym (admin only)

POST /api/gyms

Search for gyms

GET /api/gyms/search

List nearby gyms

GET /api/gyms/nearby

Check-ins

Retorna todos os itens

  GET /api/items
Parâmetro Tipo Descrição
api_key string Obrigatório. A chave da sua API

Retorna um item

  GET /api/items/${id}
Parâmetro Tipo Descrição
id string Obrigatório. O ID do item que você quer

Learning

With this project, I was able to dive deep into TDD methodology, applying unit tests to use-cases and e2e tests to all app routes. I also learned about implementing a more clean and usable code with SOLID principles, Repository pattern and best practices.

This project implements the RBCA for the users, granting or denying certain actions based on their roles.

License

MIT

gym-pass-api's People

Contributors

rozzettimatheus 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.