Hi there!
This repository is used as a foundation to start a backend environment that uses Node JS, Express and MongoDB. It offers features such as authorization middlewares (JWT auth via access and refresh token, and auth via an api key), password-based authentication (salt hashing), role module permission authorization middleware, request body validation, cron job database backup, logging, custom exception classes, and a structured folder system.
There is also session token for cookies using Lucia but it is disabled. Some features such as Google OAuth 2.0 login and Redis were not used.
Feel free to explore!
- Install dependencies:
npm i
- Run
node ./app/common/utils/generateKeys.js
to generate asymmetric encryption keys - Start PM2:
pm2 start server.config.cjs
- Run
npm run init
to setup the required configurations - Make sure to setup the
.env
file - In
docs
, you can import the Postman collection to see some of the existing apis
- Start:
pm2 start server.config.cjs
- Check logs:
pm2 log [id]
- Restart:
pm2 restart [id | all]
- Delete:
pm2 delete [id | all]
- local:
pm2 start server.config.cjs
// Default - development:
pm2 start server.config.cjs --env development
- uat:
pm2 start server.config.cjs --env uat
- production:
pm2 start server.config.cjs --env production
Check .env.sample
for the configurations needed for this repository