create-express-backend-app
v1.0.6
Published
CLI tool to generate a production-ready Express.js backend with MongoDB
Downloads
438
Maintainers
Readme
create-express-backend-app
🚀 A powerful CLI to bootstrap a scalable, production-ready Express.js backend with MongoDB.
Overview
create-express-backend-app is a command-line interface tool designed to help developers quickly set up a robust backend architecture. It provides a modular, organized structure with pre-configured MongoDB connectivity and a basic User CRUD module to get you started immediately.
Features
- 🏗 Modular Architecture: Built with scalability in mind. Code is organized by modules (Controller, Service, Model, Routes).
- ⚡ Express.js Framework: Fast, unopinionated, minimalist web framework for Node.js.
- 🍃 MongoDB & Mongoose: Pre-configured database connection and object modeling.
- 👤 User CRUD: Comes with a fully functional User module.
- 🛠 Environment Configuration: Ready-to-use
.envsupport. - 📦 Auto Dependency Install: The CLI automatically installs dependencies for you.
Installation
You can use the tool directly via npx (recommended) or install it globally.
Using Standard NPX (Recommended)
npx create-express-backend-app <your-project-name>Global Installation
npm install -g create-express-backend-appThen run:
create-express-backend-app my-new-appUsage
Open your terminal.
Run the command with your desired project name:
npx create-express-backend-app my-awesome-backendInteractive Setup: The CLI will ask you a few questions to customize your project:
- Language: Choose between TypeScript (recommended) or JavaScript.
- Database Name: Enter the name for your MongoDB database (default is
express_app). - Port: Specify the port number for the server to run on (default is 8080).
The CLI will then:
- Create a new directory named
my-awesome-backend. - Clone the boilerplate structure.
- Install all necessary dependencies (
express,mongoose,dotenv, etc.).
- Create a new directory named
Navigate into your project:
cd my-awesome-backendStart the development server:
npm run dev
Project Structure
The generated project follows a scalable, modular pattern:
my-awesome-backend/
├── src/
│ ├── config/ # Database key configurations
│ ├── constants/ # Application constants
│ ├── middlewares/ # Custom middlewares
│ ├── modules/ # Domain-specific modules
│ │ └── user/ # Example User module
│ │ ├── user.controller.js
│ │ ├── user.model.js
│ │ ├── user.routes.js
│ │ └── user.service.js
│ ├── routes/ # Main route aggregators
│ ├── utils/ # Utility functions
│ ├── app.js # Express app setup
│ └── server.js # Server entry point
├── .env.example # Environment variable examples
├── package.json
└── README.mdGetting Started with the Generated Code
Environment Setup: Rename
.env.exampleto.envand configure your MongoDB URI.PORT=3000 MONGO_URI=mongodb://localhost:27017/myappRun Server:
npm run devTest API: The User module endpoints will be available at
/api/users(checksrc/routes/index.jsfor the exact path prefix).
Contributing
Contributions are welcome! If you have suggestions or want to add features to the boilerplate:
- Fork the repository.
- Create a new branch (
git checkout -b feature/improvement). - Commit your changes.
- Push to the branch.
- Open a Pull Request.
Author
Ashwin Balas
License
This project is licensed under the ISC License.
