Backend REST API on Node.js + Express.js + Mongoose.
Create .env file in project folder
Enter these lines:
DB_STRING = "
DB_STRING_PROD = mongodb db live for production
NODE_ENV = 'development'
JWT_SECRET =
JWT_ACCESS_EXPIRATION_MINUTES=
JWT_REFRESH_EXPIRATION_DAYS=
npm start for production
npm run dev - development
src\
|--config\ # Environment variables and configuration related things
|--controllers\ # Route controllers (controller layer)
|--middlewares\ # Custom express middlewares
|--models\ # Mongoose models (data layer)
|--routes\ # Routes
|--services\ # Business logic (service layer)
|--utils\ # Utility classes and functions
|--validations\ # Request data validation schemas
|--app.js # Express app
Request data is validated using Joi.
The validation schemas are defined in the /validations
directory and are used in the routes by providing them as parameters to the validate
middleware.
The API docs can be found here - Esusu API docs