Express Standard API

A Standard Boilerplate for Node Express REST API

:gear: Dependencies

:astronaut: Development Installation

mv .env.manual .env
npm install
bash migrate.sh
npm run dev

:rocket: Production Installation

Manual

npm run build
npm run prod

Note: If you run manual installation, make sure postgre and redis server is running or that will be error

:whale: With Docker

// Build and running docker container
docker-compose build
docker-compose up

// Stop all running container
docker-compose down

:whale: List Ports Docker Containers

:camera: Screenshot

Docker Running Container Adminer Dashboard

:test_tube: Running Unit Test

Manual

npm run test

Note: If you run manual test, make sure postgre and redis server is running or that will be failed

:whale: With Docker

docker exec express-api npm run test

Note: Make sure you have run docker production installation before run it

:camera: Screenshot

Unit Test Result

:file_cabinet: Database Migrations

Manual

// Run it in Bash terminal
bash migrate.sh

Note: If you run manual migration, make sure postgre server is running or that will be error

:whale: With Docker

docker exec express-api bash migrate.sh

Note: Make sure you have run docker production installation before run it

:camera: Screenshot

Migration Result

:file_folder: Structure Folder

.
├── __test__ // Jest test file
├── database // Knex Module
├── dist // Automatically generate when you run production Installation
├── src
│   ├── controllers
│   │   └── **.ts
│   ├── helper
│   │   └── **.ts
│   ├── models
│   │   └── **.ts
│   ├── routes
│   │   └── **.ts
│   ├── app.ts // Main
│   └── index.ts // Running Sever
├── .env
├── docker-compose.yml
├── Dockerfile
├── jest.config.js // Jest Configuration
├── knexfile.ts // Knex Configuration
├── migrate.sh // Shell migrate Database
├── redis.ts // Redis Configuration
├── swagger.json // Swagger Definition
└── ...

:writing_hand: Documentations API

After you running development/production Installation you can see documentation at : http://localhost:5000/docs

:camera: Screenshot

Swagger Docs