monu-cli2
v1.0.3
Published
A simple CLI tool to scaffold an Express.js REST API with MongoDB, Swagger docs, request validation, and centralized error handling.
Maintainers
Readme
monu-cli2
monu-cli2 is a simple CLI that scaffolds an Express.js REST API with MongoDB, Swagger docs, request validation, and centralized error handling.
Installation
Install the CLI globally with npm:
npm install -g monu-cli2If you are working from this repository locally, you can link it instead:
npm linkCreate a Project
Run the CLI with the project name you want:
monu-cli2 my-appThis will:
- Create a new folder named
my-app - Initialize
package.json - Install project dependencies
- Install
nodemonas a dev dependency - Generate a ready-to-run Express API boilerplate
- Add OpenAPI comment annotations that are rendered in Swagger UI
Run the Generated Project
Move into the new project folder:
cd my-appStart the development server:
npm run devThe generated app uses this default environment file:
PORT=5000
MONGODB_URI=mongodb://127.0.0.1:27017/my-app
NODE_ENV=developmentMake sure MongoDB is running locally before starting the server.
After the app starts, Swagger docs will be available at:
http://localhost:5000/api-docsThe docs are generated from OpenAPI annotations written in the route files, then displayed with Swagger UI.
Features
- Express.js API scaffold
- MongoDB connection with Mongoose
- OpenAPI annotations with Swagger UI documentation
- Request validation with
express-validator - Global error handling
- Sample user CRUD routes
- Pre-configured middleware with
cors,morgan, and JSON parsing
Generated Structure
my-app/
|-- config/
| |-- db.js
| `-- swagger.js
|-- controllers/
| `-- user.controller.js
|-- middleware/
| `-- globalErrorHandler.js
|-- models/
| `-- user.model.js
|-- routes/
| `-- user.router.js
|-- .env
|-- .gitignore
|-- package.json
`-- server.jsLicense
This project is licensed under the ISC License.
