Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/murilodamarioo/gympass-style-app
https://github.com/murilodamarioo/gympass-style-app
docker-compose fastify jwt typescipt
Last synced: about 21 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/murilodamarioo/gympass-style-app
- Owner: murilodamarioo
- Created: 2024-12-16T00:35:31.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2025-01-10T20:08:59.000Z (7 days ago)
- Last Synced: 2025-01-10T21:20:08.451Z (7 days ago)
- Topics: docker-compose, fastify, jwt, typescipt
- Language: TypeScript
- Homepage:
- Size: 142 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐โจ **API Documentation**
## ๐๐ **Project** **Gympass Style App**
## RFs (Functional Requirements)
- [X] It must be possible to register;
- [X] It must be possible to authenticate;
- [X] It must be possible to retrieve the profile of a logged-in user;
- [X] It must be possible to get the number of check-ins performed by the logged-in user;
- [X] It must be possible for the user to access their check-in history;
- [X] It must be possible for the user to search for nearby gyms (10km);
- [X] It must be possible for the user to search for gyms by name;
- [X] It must be possible for the user to check in at a gym;
- [X] It must be possible to validate a user's check-in;
- [X] It must be possible to register a gym;## RNs (Business Rules)
- [X] User must not be able to register with a duplicate email;
- [X] User cannot perform more than one check-in on the same day;
- [X] User cannot check in unless they are within 100 meters of the gym;
- [X] Check-in can only be validated up to 20 minutes after it is created;
- [X] Check-in can only be validated by administrators;
- [X] A gym can only be registered by administrators;## RNFs (Non-Functional Requirements)
- [X] User passwords must be encrypted;
- [X] Application data must be persisted in a PostgreSQL database;
- [X] All data lists must be paginated with 20 items per page;
- [X] Users must be identified by a JWT (JSON Web Token);---
## ๐ ๏ธ๐ป **Technologies Used**
- ๐ข **Language:** [Node.js, Typescript]
- ๐๏ธ **Framework:** [Fastify]
- ๐๏ธ **Database:** [PostgreSQL]
- ๐ **Authentication:** [JWT]
- ๐ข **Other Technologies:** [Docker, CI]---
## ๐ฆโ๏ธ **Installation & Configuration**
1๏ธโฃ **๐ฅ Clone the repository:**
```bash
git clone https://github.com/murilodamarioo/gympass-style-app.git
```2๏ธโฃ **๐ Navigate to the project directory:**
```bash
cd gympass-style-app
```3๏ธโฃ **๐ฆ Install dependencies:**
```bash
npm install
```4๏ธโฃ **๐ Set up environment variables:**
Create a `.env` file based on `.env.example` and adjust as needed.5๏ธโฃ **๐ Start the server:**
```bash
npm start
```
---
## ๐ข Docker ContainerTo up a PostgreSQL Container
```bash
docker compose up -d
```To stop PostgreSQL image
```bash
docker compose stop
```---
## ๐๐ก๏ธ **Authentication**
This API uses **๐ JWT (JSON Web Token)** for authentication. Make sure to include the token in the ๐จ header of protected requests.
**๐ Header Example:**
```http
Authorization: Bearer
```---
## ๐๐ **Main Endpoints**
### ๐๐ค **1. Register User**
- ๐ ๏ธ **Method:** `POST`
- ๐ **URL:** `/users`
- ๐ **Description:** Registers a new user.
- ๐จ **Request:**
```json
{
"name": "string",
"email": "string",
"password": "string"
}
```
- ๐ค **Response:**
```json
{
"status": 201,
}
```### ๐ **2. Authenticate User**
- ๐ ๏ธ **Method:** `POST`
- ๐ **URL:** `/sessions`
- ๐ **Description:** Authenticates a user.
- ๐จ **Request:**
```json
{
"email": "string",
"password": "string"
}
```
- ๐ค **Response:**
```json
{
"status": 200,
"token": "string"
}
```### ๐ค **4. Get Profile**
- ๐ ๏ธ **Method:** `GET`
- ๐ **URL:** `/me`
- ๐ **Description:** Returns authenticated user profile.
- ๐ค **Response:**
```json
{
"status": 200,
"id": 1,
"name": "John Doe",
"email": "[email protected]"
}
```### ๐๏ธโโ๏ธ **5. Search Gyms**
- ๐ ๏ธ **Method:** `GET`
- ๐ **URL:** `/gyms/search`
- ๐ **Description:** Searches gyms by query.
- - ๐จ **Query Params:**
```json
{
"query": "string",
"page": "number"
}
```
- ๐ค **Response:**
```json
{
"status": 200,
"gyms": []
}
```### ๐ **6. Nearby Gyms**
- ๐ ๏ธ **Method:** `GET`
- ๐ **URL:** `/gyms/nearby`
- ๐ **Description:** Finds nearby gyms.
- ๐ค **Response:**
```json
{
"status": 200,
"gyms": []
}
```### ๐๏ธ **7. Create Gym (ADMIN)**
- ๐ ๏ธ **Method:** `POST`
- ๐ **URL:** `/gyms`
- ๐ **Description:** Creates a new gym.
- - ๐จ **Request:**
```json
{
"title": "string",
"description": "string",
"phone": "string",
"latitude": "number",
"longitude": "number"
}
```
- ๐ค **Response:**
```json
{
"status": 201,
}
```### ๐ **8. Check-in History**
- ๐ ๏ธ **Method:** `GET`
- ๐ **URL:** `/check-ins/history`
- ๐ **Description:** Retrieves check-in history.
- ๐ค **Response:**
```json
{
"status": 200,
"checkIns": [
"id": "string",
"created_at": "Date",
"validated_at": "Date",
"gym_id": "string",
"user_id": "string",
]
}
```### ๐ **9. Check-in Metrics**
- ๐ ๏ธ **Method:** `GET`
- ๐ **URL:** `/check-ins/metrics`
- ๐ **Description:** Displays check-in metrics.
- ๐ค **Response:**
```json
{
"status": 200,
"checkInsCount": 10
}
```### โ **10. Validate Check-in (Admin)**
- ๐ ๏ธ **Method:** `PATCH`
- ๐ **URL:** `/check-ins/:checkInId/validate`
- ๐ **Description:** Validates a check-in.
- ๐ค **Response:**
```json
{
"status": 204,
}
```
---## ๐งช **Tests**
### 1. **Unit Tests**
Runs all unit tests located in the `test/` directory.
```bash
npm run test
````Runs the tests and watches for changes in the test/ directory. Tests will automatically rerun on any changes.
```bash
npm run test:watch
````### 2. **E2E Tests**
Runs the tests for integration/HTTP files located in the `src/http` directory, typically used for testing client-server communication.
```bash
npm run test:e2e
````
### 3. Test Coverage
Runs all tests and generates a coverage report, showing the percentage of code covered by tests.
```bash
npm run test:coverage
````