Skip to content

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