Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mhp24/ferremax-api


https://github.com/mhp24/ferremax-api

Last synced: 18 days ago
JSON representation

Awesome Lists containing this project

README

        

Ferremax API



Ferremax logo











## Table of contents
- [About this project](#about-this-project)
- [Setup and installation](#setup-and-installation)
- [Production demo](#production-demo)
- [Quick stage demo](#quick-stage-demo)
- [API Spec & Documentation](#api-spec-documentation)
- [Testing](#testing)

## About this project ๐Ÿ“•
This is a project based in a [template](https://github.com/MHP24/nestjs-template) created by [MHP24](https://github.com/MHP24) that includes a development setup and environment multi OS support ready-to-use outside the box, and has the config ready for:


  • ESLint

  • Prettier integration

  • Docker hot reload feature (Windows supported)

  • Husky integration

  • Commit lint (Conventional commits standard)

  • Joi .env validation schema

## Setup and installation ๐Ÿš€

Before using this template, ensure you have [Node.js](https://nodejs.org/en) installed (version 20.12.0 for this template) and [Docker (optional)](https://www.docker.com/) installed and running.

### Steps

1 . Install dependencies using [yarn __(required)__](https://yarnpkg.com/) as package manager:
```bash
yarn
```

2 . Replace __.env.template__ file variables and rename it as __.env__ file

#### __Environment variables specification__ ย 

|__Variable__|__Type__|__Description__|
|---|---|---|
PORT | Integer (positive) | Port where app runs |
DB_URL | String | URL connection string for the PostgreSQL database __used by PrismaORM__ |
JWT_SECRET | String | Secret key for signing JWTs |
JWT_REFRESH_SECRET | String | Secret key for signing refresh JWTs |
JWT_EXPIRE_TEXT | String | Expiration time for JWTs in a readable format (e.g. "12h") |
JWT_REFRESH_EXPIRE_TEXT | String | Expiration time for refresh JWTs in a readable format (e.g. "1d")
JWT_EXPIRE_SECONDS | Integer (positive) | Expiration time for JWTs in seconds |
DB_NAME | String | Name of the PostgreSQL database (can be provided for docker container) |
DB_HOST | String | Host address of the PostgreSQL database (can be provided for docker container) |
DB_PORT | Integer (positive) | Port on which the PostgreSQL database (can be provided for docker container) |
DB_USER | String | Username for the PostgreSQL database (can be provided for docker container) |
DB_PASSWORD | String | Password for the PostgreSQL database (can be provided for docker container) |
STATIC_FILE_PATH | String | Path for static files directory (Outside src) |



3 . __Database setup__ using PrismaORM (needs PostgreSQL database available, feel free to use docker-compose.dev.yml)
```bash
yarn prisma:init
```

4 . __Start development mode:__ Start the development server:
```bash
yarn start:dev
```

5 . __Populate database using seed endpoint__
```bash
POST to: http://127.0.0.1:PORT/api/v1/seed
```

## Production demo ๐Ÿ“Ÿ
Demo available at: https://ferremax-api.mg-hp.com/api/v1/docs

## Quick stage demo โญ

To start a quick demo you must to have [Docker](https://www.docker.com/) installed and running.

### Steps

1 . __Configure .env file__: Follow instructions from [Setup and installation](#setup-and-installation) -> Step 2

2 . __Start Docker stage compose file__
```bash
docker compose -f docker-compose.stage-local.yml up
```

## API Spec & Documentation ๐Ÿ“—

If your app is running correctly you will find the specification at: http://127.0.0.1:PORT/api/v1/docs

## Testing ๐Ÿงช
You have 2 options for testing environment:

1 . __Docker__:

To start the testing environment with Docker, use the following command:
```bash
docker compose -f docker-compose.testing.yml up --build
```

2 . __Node (Jest)__:

To run tests with Jest in a Node environment, use the following command:
```bash
yarn test
```