ipang-dwi/express-standard-api

a Standard Boilerplate for Node Express REST API

โ˜… 5Forks 0GitHub โ†—Compare

README

Express Standard API

A Standard Boilerplate for Node Express REST API

โš™๏ธ Dependencies

๐Ÿง‘โ€๐Ÿš€ Development Installation

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

๐Ÿš€ 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

๐Ÿณ With Docker

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

// Stop all running container
docker-compose down

๐Ÿณ List Ports Docker Containers

  • 5000:5000 Express Rest API
  • 5400:5432 PostgreSQL
  • 6379:6379 Redis
  • 8080:8080 Adminer

๐Ÿงช Running Unit Test

npm run test

๐Ÿ—„๏ธ Database Migrations

// Run it in Bash terminal
bash migrate.sh

๐Ÿ“ 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
โ””โ”€โ”€ ...

โœ๏ธ Documentations API

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

Contributors

munirappmnr2nd

Issues