Nodejs-Restapi-Boilerplate
Boilerplate for API backends with Node.js and Express.
Directory structure
Overview
Project src
structure directories.
src/
├─ config/
│ ├─ config.js
├─ controller.js
│ ├─ controller.index.js
│ ├─ userController.js
├─ loader/
│ ├─ express.js
│ ├─ mongoose.js
│ ├─ server.js
├─ middlewares/
│ ├─ middlewares.index.js
│ ├─ validator.js
├─ routes/
│ ├─ routes.index.js
│ ├─ routes.js
│ ├─ userRoute.js
├─ utils/
│ ├─ requestUtil.js
│ ├─ utils.index.js
test/
├─ example.test.js
├─ userController.test.js
└─
Features
- ES9: latest ECMAScript features
- NoSQL database: MongoDB object data modeling using Mongoose
- Authentication and authorization: using jsonwebtoken
- Validation: request data validation using Joi
- Logging: //TODO: winston
- Testing: unit and integration tests using Mocha Chai
- Error handling: centralized error handling mechanism
- API documentation: //TODO: swagger
- Dependency management: with Npm
- Environment variables: using dotenv
- Security: //TODO: set security HTTP headers using helmet
- Santizing: sanitize request data against xss and query injection
- CORS: //TODO: Cross-Origin Resource-Sharing enabled using cors
- Compression: //TODO: gzip compression with compression
- CI: continuous integration with Travis CI
- Docker support
- Code coverage: using coveralls
- Code quality: with Codacy
- Git hooks: //TODO: with husky and lint-staged
- Linting: with ESLint and Prettier
- Editor config: consistent editor configuration using EditorConfig