Skip to content

Commit 3b2548c

Browse files
committed
chore: merge dev into main for release v1.0.0
2 parents 168b680 + 8395e8a commit 3b2548c

99 files changed

Lines changed: 11629 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

β€Ž.env.exampleβ€Ž

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
NODE_ENV=dev
2+
3+
# Auth
4+
JWT_SECRET=
5+
6+
# Database
7+
PORT=
8+
DATABASE_URL=

β€Ž.eslintignoreβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
build

β€Ž.eslintrc.jsonβ€Ž

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": [
3+
"@rocketseat/eslint-config/node"
4+
],
5+
"rules": {
6+
"camelcase": "off",
7+
"no-useless-constructor":"off"
8+
}
9+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Run E2E Tests
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
run-e2e-tests:
7+
name: Run E2E Tests
8+
runs-on: ubuntu-latest
9+
10+
services:
11+
postgres:
12+
image: bitnami/postgresql
13+
ports:
14+
- 5432:5432
15+
env:
16+
POSTGRESQL_USERNAME: docker
17+
POSTGRESQL_PASSWORD: docker
18+
POSTGRESQL_DATABASE: gogymapi
19+
20+
steps:
21+
- uses: actions/checkout@v3
22+
23+
- uses: actions/setup-node@v3
24+
with:
25+
node-version: 18
26+
cache: 'npm'
27+
28+
- run: npm ci
29+
30+
- run: npm run test:e2e
31+
env:
32+
JWT_SECRET: testing
33+
DATABASE_URL: "postgres://docker:docker@localhost:5432/gogymapi?schema=public"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Run Unit Tests
2+
3+
on: [push]
4+
5+
jobs:
6+
run-unit-tests:
7+
name: Run Unit Tests
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-node@v3
13+
with:
14+
node-version: 18
15+
cache: 'npm'
16+
17+
- run: npm ci
18+
19+
- run: npm run test

β€Ž.gitignoreβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
build
3+
coverage
4+
.env
5+
/generated/prisma

β€Ž.npmrcβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-exact=true

β€ŽREADME.mdβ€Ž

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,123 @@
11
# gogym-api
22
Application for registration and check-in at gyms
3+
# πŸ‹οΈ GoGym - Gym Check-in Management System
4+
5+
GoGym is a modern and efficient gym check-in management application built with **Node.js** and **Fastify**. It allows gym owners to manage their facilities and users to easily check in with a seamless experience.
6+
7+
## πŸš€ Features
8+
9+
- **User Register**: Members can be registered on application.
10+
- **User Check-in**: Members can check in to gyms quickly and securely.
11+
- **Gym Management**: Owners can manage gym locations, memberships, and check-ins.
12+
13+
## πŸ”§ Technologies Used
14+
15+
- **Node.js** (Backend Runtime)
16+
- **Fastify** (Web Framework)
17+
- **Zod** (Schema Validation)
18+
- **dotenv** (Environment Variables)
19+
- **Prisma** (Serverless architecture ORM)
20+
- **BCryptjs** (Hashing lib for passwords)
21+
- **Vitest** (Unit tests enviroment)
22+
23+
## πŸ“‚ Project Structure
24+
```bash
25+
go-gym-api/
26+
β”œβ”€β”€ prisma/
27+
β”‚ β”œβ”€β”€ migrations # stored migration history
28+
β”‚ └── schema.prisma # Database tables schemas
29+
β”œβ”€β”€ src/
30+
β”‚ β”œβ”€β”€ @types/ # Store globals interfaces on project
31+
β”‚ β”œβ”€β”€ env/
32+
β”‚ β”‚ └── index.ts # Enviroment vars validation
33+
β”‚ β”œβ”€β”€ http/
34+
β”‚ β”‚ β”œβ”€β”€ controllers/ # Handler of request response
35+
β”‚ β”‚ └── middlewares # Functions to interact between controllers and endpoints
36+
β”‚ β”œβ”€β”€ lib/
37+
β”‚ β”‚ └── prisma.ts # Prisma client config
38+
β”‚ β”œβ”€β”€ repositories/ # Layer for database manipulation tools
39+
β”‚ β”‚ β”œβ”€β”€ in-memory/
40+
β”‚ β”‚ β”œβ”€β”€ prisma/
41+
β”‚ β”‚ β”œβ”€β”€ check-ins-repository.ts # Check-ins Interface
42+
β”‚ β”‚ β”œβ”€β”€ gyms-repository.ts # Check-ins Interface
43+
β”‚ β”‚ └── users-repository.ts # Users Interface
44+
β”‚ β”œβ”€β”€ use-cases/ # Use cases layer for entities
45+
β”‚ β”‚ β”œβ”€β”€ errors/ # Use case error messages
46+
β”‚ β”‚ └── factories/ # Use case factories for instances
47+
β”‚ β”œβ”€β”€ utils/ # Application utility functions
48+
β”‚ β”‚ └── test/ # Utility functions for tests
49+
β”‚ β”œβ”€β”€ app.ts # Fastify app setup
50+
β”‚ └── server.ts # Server setup config
51+
β”œβ”€β”€ env.example # Enviroment variables example
52+
β”œβ”€β”€ .eslintrc.json # ESLint Config
53+
β”œβ”€β”€ .gitignore
54+
β”œβ”€β”€ .npmrc # NPM config libs control
55+
β”œβ”€β”€ docker-compose.yml
56+
β”œβ”€β”€ LICENSE
57+
β”œβ”€β”€ package.json
58+
β”œβ”€β”€ tsconfig.json
59+
β”œβ”€β”€ vite.config.ts # Unit test config file
60+
└── README.md
61+
```
62+
63+
## βš™οΈ Setup & Installation
64+
65+
1. **Clone the repository**:
66+
```bash
67+
git clone https://github.com/DevAnseSenior/gogym-api.git
68+
cd go-gym-api
69+
```
70+
71+
2. **Install dependencies**:
72+
```bash
73+
npm install
74+
```
75+
76+
3. **Set up environment variables (create *.env* file)**:
77+
```bash
78+
NODE_ENV="your_env" ("dev", "test", "production")
79+
PORT=3333
80+
DATABASE_URL=
81+
```
82+
83+
4. **Run the application**:
84+
```bash
85+
docker compose up -d # Start the services
86+
npx prisma migrate dev # Execute migrations
87+
npm run start:dev # Run application on development mode
88+
```
89+
90+
The API will be available at http://localhost:3333
91+
92+
5. **Run tests**:
93+
```bash
94+
docker compose up -d # Start the services
95+
npm run test # Run the unit tests suits
96+
npm run test:e2e # Run the tests e2e suits
97+
npm run test:watch # Run the tests on watch mode
98+
npm run test:coverage # Verify the tests coverage (open index.html from dir coverage/)
99+
npm run test:ui # Execute the test client of vitest
100+
```
101+
102+
## πŸ“Œ Endpoints (Example)
103+
### Users
104+
- POST /users β†’ Register new user.
105+
- POST /sessions β†’ Authenticate (login).
106+
- GET /me β†’ Get logged user info.
107+
108+
### Gyms
109+
- POST /gyms β†’ Create a new gym.
110+
- GET /gyms/search β†’ Search gym by title.
111+
- GET /gyms/nearby β†’ Search nearby user localization gyms.
112+
113+
### Check-ins
114+
- POST /gyms/:gymId/check-ins β†’ Check-in.
115+
- PATCH /check-ins/:checkInId/validate β†’ Gym validations check-in.
116+
- GET /check-ins/history β†’ Get check-ins history.
117+
- GET /check-ins/metrics β†’ Get check-ins count of logged user.
118+
119+
## πŸ“„ License
120+
This project is licensed under MIT [License](./LICENSE).
121+
122+
Made with πŸ’ͺ by Anderson Coelho
123+
πŸš€ Powered by Fastify & Node.js

β€Ždocker-compose.ymlβ€Ž

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
services:
2+
gogym-api-pg:
3+
image: bitnami/postgresql
4+
ports:
5+
- 5432:5432
6+
environment:
7+
- POSTGRESQL_USERNAME=docker
8+
- POSTGRESQL_PASSWORD=docker
9+
- POSTGRESQL_DATABASE=gogymapi

0 commit comments

Comments
Β (0)