-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d0fa58c
Showing
103 changed files
with
9,225 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
NODE_ENV=dev | ||
|
||
#Auth | ||
JWT_SECRET=ignitenode03 | ||
|
||
# Database | ||
DATABASE_URL="postgresql://user:password@localhost:5432/ignitenode03?schema=public" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": [ | ||
"@rocketseat/eslint-config/node" | ||
], | ||
"rules": { | ||
"camelcase": "off", | ||
"no-useless-constructor": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Run E2E Tests | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
run-e2e-tests: | ||
name: Run E2E Tests | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
api-solid-pg: | ||
image: bitnami/postgresql | ||
ports: | ||
- 5432:5432 | ||
env: | ||
POSTGRESQL_USERNAME: docker | ||
POSTGRESQL_PASSWORD: docker | ||
POSTGRESQL_DATABASE: ignitenode03 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
cache: 'npm' | ||
|
||
- run: npm ci | ||
|
||
- run: npm run test:e2e | ||
env: | ||
JWT_SECRET: testing | ||
DATABASE_URL: "postgresql://docker:docker@localhost:5432/ignitenode03?schema=public" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Run Unit Tests | ||
|
||
on: [push] | ||
|
||
jobs: | ||
run-unit-tests: | ||
name: Run Unit Tests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
cache: 'npm' | ||
|
||
- run: npm ci | ||
|
||
- run: npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules | ||
build | ||
|
||
coverage | ||
|
||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
save-exact=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<h2 align="center"> | ||
<div> | ||
<img alt="Logo" width="100" title="#logo" src="preview/icon.svg" /> | ||
</div> | ||
</h2> | ||
|
||
<h1 align="center"> | ||
API Node.js com SOLID | GymPass API REST 💻🚀 | ||
<h1> | ||
|
||
|
||
<h1 align="center"> | ||
<div style="display: flex; flex-direction: row;"> | ||
<img width="400" style="border-radius: 10px" height="auto" alt="Class-01" title="Class-01" src="./preview/preview.gif" /> | ||
<img width="400" style="border-radius: 10px" height="auto" alt="Class-02" title="Class-02" src="./preview/test-unit.gif" /> | ||
</div> | ||
</h1> | ||
|
||
API REST desenvolvida no módulo Ignite da Rocketseat. O projeto utiliza conceitos de clean architecture, factory pattern, autenticação JWT e geolocalização. | ||
|
||
A aplicação GymPass tem como objetivo gerenciar o tráfego de clientes em academias. Os usuários podem realizar o check-in nas academias, porém o check-in só é permitido se o usuário estiver a uma distância de até 100 metros da academia. | ||
|
||
|
||
<h2 id="technologies"> 🛠 Tecnologias utilizadas: </h2> | ||
|
||
- `prisma`: ORM para banco de dados. | ||
- `supertest`: Testes de API. | ||
- `tsup`: Compilação TypeScript. | ||
- `tsx`: Suporte para TSX. | ||
- `typescript`: Linguagem de programação. | ||
- `vitest`: Ferramenta de teste. | ||
- `fastify`: Framework web (Fastify). | ||
- `zod`: Validação de dados (Zod). | ||
|
||
## RFs (Requisitos funcionais) | ||
|
||
- [x] Deve ser possível se cadastrar; | ||
- [x] Deve ser possível se autenticar; | ||
- [x] Deve ser possível obter o perfil de um usuário logado; | ||
- [x] Deve ser possível obter o número de check-ins realizados pelo usuário logado; | ||
- [x] Deve ser possível o usuário obter o seu histórico de check-ins; | ||
- [x] Deve ser possível o usuário buscar academias próximas (até 10km); | ||
- [x] Deve ser possível o usuário buscar academias pelo nome; | ||
- [x] Deve ser possível o usuário realizar check-in em uma academia; | ||
- [x] Deve ser possível validar o check-in de um usuário; | ||
- [x] Deve ser possível cadastrar uma academia; | ||
|
||
## RNs (Regras de negócio) | ||
|
||
- [x] O usuário não deve poder se cadastrar com um e-mail duplicado; | ||
- [x] O usuário não pode fazer 2 check-ins no mesmo dia; | ||
- [x] O usuário não pode fazer check-in se não estiver perto (100m) da academia; | ||
- [x] O check-in só pode ser validado até 20 minutos após ser criado; | ||
- [x] O check-in só pode ser validado por administradores; | ||
- [x] A academia só pode ser cadastrada por administradores; | ||
|
||
## RNFs (Requisitos não-funcionais) | ||
|
||
- [x] A senha do usuário precisa estar criptografada; | ||
- [x] Os dados da aplicação precisam estar persistidos em um banco PostgreSQL; | ||
- [x] Todas listas de dados precisam estar paginadas com 20 itens por página; | ||
- [x] O usuário deve ser identificado por um JWT (JSON Web Token); | ||
|
||
<h2 id="usage" > 👷 Requisitos </h2> | ||
|
||
Install git, node and yarn (or npm). | ||
|
||
```bash | ||
# Clone Repository | ||
$ git clone https://github.com/Gustavo-Developer/gympass-api.git | ||
|
||
# Go to server folder | ||
$ cd api-03-solid-rocketseat | ||
|
||
# Install Dependencies | ||
$ npm install | ||
|
||
|
||
# rename file .env.example to .env | ||
|
||
# run docker compose | ||
$ docker compose up -d | ||
|
||
# run prisma | ||
$ npx prisma migrate dev | ||
|
||
# Run Tests | ||
$ npm run test | ||
$ npm run test:e2e | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: '3' | ||
|
||
services: | ||
api-solid-pg: | ||
image: bitnami/postgresql | ||
ports: | ||
- 5432:5432 | ||
environment: | ||
- POSTGRESQL_USERNAME=docker | ||
- POSTGRESQL_PASSWORD=docker | ||
- POSTGRESQL_DATABASE=ignitenode03 |
Oops, something went wrong.