This is a template for building applications using Node.js, Express, and Mongoose. It includes a structured approach to organizing your code and handling your MongoDB database with Mongoose.
- Organized project structure
- Mongoose as ORM for MongoDB
- Bunyan for logging
- Environment-specific configurations
- Define required variables in
development.json
.
- Define required variables as environment variables in your remote setup.
- MongoDB
models
: Contains Mongoose model definitions.controllers
: Contains business logic for handling requests.routes
: Contains Express route definitions, which should correspond to controllers.middlewares
: Contains custom middleware functions.config
: Contains configuration files and settings.
- All logging should be done using
req.log
, which utilizes Bunyan. - For model-level logging, pass
req.log
to underlying layers.
We welcome contributions to this project. To maintain consistency and quality, please follow these guidelines:
- Models: Every MongoDB collection should have a corresponding Mongoose model in the
models
folder. - Controllers and Routes: The
controllers
androutes
folders should mirror each other. Each route inroutes
should have a corresponding file or folder incontrollers
. - Logging: Use
req.log
for logging purposes. For model-level operations, ensurereq.log
is passed to the required layers.
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature-branch
). - Open a pull request.
This project is licensed under the MIT License.