xpresso-cli
v1.3.1
Published
A CLI tool to scaffold Express.js applications.
Maintainers
Readme
🚀 xpresso-cli
A powerful, incredibly fast CLI tool to instantly scaffold production-ready Node.js Express applications. It comes packed with built-in database configurations and an intuitive modular service generator, saving you hours of boilerplate setup.
✨ Features
- ⚡ Instant Setup: Scaffolds a complete, production-ready Express.js MVC/Modular server structure in seconds.
- 🗄️ Database Ready: Automatic, hassle-free database setup for MongoDB (Mongoose) or PostgreSQL (Sequelize).
- 🛠️ Service Generator: Built-in CLI command to automatically generate new service modules (Controllers, Models, Routes) instantly.
- 🔒 Best Practices Built-in: Pre-configured
app.jswith CORS, compression, and global error handlers. - 📦 Package Manager Choice: Support for
npm,yarn, andpnpm.
📖 Step-by-Step Guide
Step 1: Scaffold a New Application
You can use npx to create a new application instantly without installing anything globally:
npx xpresso-cli my-appAlternatively, you can install the CLI globally:
npm install -g xpresso-cliThen you can use it directly anywhere:
xpresso-cli my-app(If you run the command without a folder name, the CLI will interactively ask you for it!)
Step 2: Configure Your Project
The interactive CLI will prompt you to make a few quick decisions to tailor your app:
- Package Manager: Choose between
npm,yarn, orpnpm. - Database: Select your preferred database:
MongoDB(uses Mongoose)PostgreSQL(uses Sequelize)None(if you want to set it up yourself later)
Once selected, the CLI will automatically:
- Generate the folder structure.
- Configure your database connection file.
- Generate an initial
authservice tailored to your database choice. - Install all necessary dependencies automatically!
Step 3: Run Your Application
Navigate into your newly created project and start the development server:
cd my-app
npm start(If you selected yarn or pnpm, use yarn start or pnpm start respectively).
You now have a fully functional Node.js server running! 🎉
🏗️ Generating New Services (The Magic)
Once your application is created, xpresso-cli provides an amazing built-in code generator that saves you from writing repetitive boilerplate for new features.
To generate a new service (e.g., for user management), navigate into your project folder and run:
npx create-service user(If you installed the CLI globally, you can simply type create-service user)
What happens behind the scenes?
When you run create-service user, the CLI automatically:
- Creates a Controller (
services/user/controller/user.controller.js). - Creates Routes (
services/user/routes/user.routes.js). - Creates a Model (
services/user/model/user.model.js) specifically tailored to the database you selected during initial setup! - Auto-wires everything: It automatically updates your main
app.jsfile to import and register your newuserroutes. You don't have to touch a thing!
📂 Folder Structure
Here is the clean, modular structure generated for your app:
my-app/
├── bin/
│ └── www # Server startup script
├── config/
│ └── db.config.js # Database connection setup
├── public/ # Static files
├── services/
│ ├── auth/ # Automatically generated on init
│ │ ├── controller/
│ │ ├── model/
│ │ └── routes/
│ └── <your-service>/ # Automatically generated via 'create-service'
├── utils/
│ └── helper.utils.js # Helper functions and utilities
├── app.js # Express app configuration (auto-updated with new routes)
└── package.json # Project dependencies and scripts🤝 Contributing
Contributions, issues, and feature requests are always welcome! Feel free to check the issues page.
📄 License
This project is licensed under the ISC License.
Created with ❤️ by Krish Dhiman
