This is a codebase/boilerplate for Back End REST API using express. You can use it as a starter project for creating APIs.
- expressJS
- mongoDB (for databases)
- minio (for object storage)
- Joi (for input validation)
- jose (for JWT sign & verification)
- argon2 (for password hashing)
- index.js -> root files
- bin
- app
- routes -> all routes goes here (1 file / modules)
- helpers
- configs
- modules
- moduleName -> modules represent entity
- queries -> queries where all the fetching data endpoint goes (GET)
- handler.js -> this is like a controller who responsible to validate input and return output of an endpoint
- query_model.js -> this file to store Joi schema for input validation
- domain.js -> this file to put every logic of an endpoint
- query.js -> this file to put function related to database
- commands -> commands is the place where every other method goes (POST, PUT, DELETE, PATCH)
- handler.js
- command_model.js
- domain.js
- command.js
- queries -> queries where all the fetching data endpoint goes (GET)
- moduleName -> modules represent entity
- app
- make sure you have minio server and mongoDB server run on your laptop.
- Clone this repository
git clone https://github.com/ferigalung/express-rest-boiler-plate.git
. - Install the dependency
npm install
. - copy file
env.example
and paste to the same dir and rename it to.env
. - Run the dev server
npm run dev
.