This boilerplate provides a starting point for building scalable and efficient backend applications using Node.js, Express, and MongoDB. It follows best practices and patterns for API development and is structured to be easily extensible.
- Express.js: Fast, unopinionated, minimalist web framework for Node.js.
- MongoDB: NoSQL database for modern applications.
- Mongoose: MongoDB object modeling tool designed to work in an asynchronous environment.
- Dotenv: Loads environment variables from a
.env
file intoprocess.env
. - Config: Loads config variables from a
/config/default.cjs
and can be accessed withconfig.get("string pointing to config value")
. - CORS: Node.js package for providing a Connect/Express middleware that can be used to enable CORS.
- Error Handling: Centralized error handling mechanism.
- Validation: Request data validation using express-validator.
- Logging: Using morgan & winston.
- Authentication: Using JWT.
- Code Linting: Using Prettier.
backend-boilerplate/
│
├── config/ # Environment variables and configuration related stuff
├── src/
│ ├── controllers/ # Route controllers (controller layer)
│ ├── helpers/ # Api helpers
│ ├── middlewares/ # Custom express middlewares
│ ├── models/ # Mongoose models (data layer)
│ ├── routes/ # Routes (express route definitions)
│ ├── startup/ # Utility startup functions
│ └── index.js # Express app
│
├── .gitignore # Specifies intentionally untracked files to ignore
├── package.json # Node module dependencies and scripts
├── README.md # Project overview
└── .prettierrc.cjs
- Node.js
- MongoDB
-
Clone the repository:
git clone https://github.com/ikemHood/Backend_Boilerplate.git cd Backend_Boilerplate
-
Install NPM packages:
npm install
-
Configure environment variables:
set system.port and mongo_db.uri
-
Run the server:
npm start
or for development:
npm run dev
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License.
Name – ikem Peter Email: ikem@ikem.dev