Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

munirapp/express-standard-api

Repository files navigation

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

πŸ“· Screenshot

Docker Running Container Adminer Dashboard

πŸ§ͺ 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

🐳 With Docker

docker exec express-api npm run test

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

πŸ“· Screenshot

Unit Test Result

πŸ—„οΈ 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

🐳 With Docker

docker exec express-api bash migrate.sh

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

πŸ“· Screenshot

Migration Result

πŸ“ 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

πŸ“· Screenshot

Swagger Docs

About

a Standard Boilerplate for Node Express REST API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages