@express-tool/cli
v2.0.1
Published
Production-grade CLI for Express.js applications
Maintainers
Readme
🚀 Express Tool CLI
A production-grade Command Line Interface for generating robust, scalable Express.js applications.
express-tool automates the boring setup, enforcing best practices, modern tooling, and clean architecture from day one.
✨ Features
- Language Support: First-class TypeScript support (recommended) or modern JavaScript (ES Modules).
- Architecture: Choose between Feature-based (great for scalability) or Classic MVC.
- Database Integration:
- Prisma ORM: PostgreSQL (Self-managed or Managed), MySQL, MongoDB.
- Mongoose: Native MongoDB support.
- Authentication: Built-in simple JWT authentication boilerplate.
- Template Engines: Support for Server-Side Rendering (SSR) with EJS or Pug.
- API Documentation: Automatic Swagger/OpenAPI options.
- Package Managers: Support for
npm,pnpm,yarn, andbun. - Production Ready:
- 🐳 Docker & Docker Compose setup included.
- 🧪 Testing with Vitest + Supertest.
- 🧹 Linting & Formatting (ESLint + Prettier + Husky).
- 📝 Structured logging with Pino.
📦 Installation
Install globally via your preferred package manager:
npm
npm install -g @express-tool/clipnpm (Recommended)
pnpm add -g @express-tool/cliYarn
yarn global add @express-tool/cliBun
bun add -g @express-tool/cli⚡ Execution without Installation
You can also execute the CLI instantly without installing it globally:
npx (Node.js)
npx @express-tool/cli initpnpm dlx
pnpm dlx @express-tool/cli initbunx
bunx @express-tool/cli init🛠 Usage
1. Initialize a New Project
The init command launches an interactive wizard to configure your new application.
express-tool initInteractive Prompts:
- Project Name: Name of your project directory (kebab-case).
- Language:
TypeScript(Recommended) orJavaScript. - Package Manager: Select
npm,pnpm,yarn, orbun. - Architecture:
Feature-based: Groups files by domain feature (e.g.,src/modules/users/).MVC: Classic layering (src/controllers,src/routes,src/models).
- API Type:
REST API + Swagger: Includes setup for auto-generated API docs.REST API (Basic): Simple setup without documentation tools.
- Database:
PostgreSQL (Prisma)PostgreSQL (Prisma Postgres Managed)MySQL (Prisma)MongoDB (Mongoose)None
- Authentication:
JWT (JSON Web Token)None
- Template Engine:
EJSPugNone (API only)
- Linting: (Yes/No) Include ESLint & Prettier.
- Runtime Validation: (Yes/No) Include Zod.
2. Generate Resources (generate or g)
Quickly scaffold new resources (features) into your existing application. This command respects your project's language (TS/JS).
Syntax:
express-tool generate <resource-name>
# or shorcut
express-tool g <resource-name>Example:
express-tool g blogsOutput:
This will create the following files (example for a blogs feature):
- 📄
src/controllers/blogs.controller.ts(CRUD handlers) - 🛣️
src/routes/blogs.routes.ts(Router definition) - 🧪
test/blogs.test.ts(Integration tests)
After Generation:
The CLI will print instructions on how to register the new route in your src/index.ts (or app.ts):
import { blogsRouter } from './routes/blogs.routes.js';
app.use('/blogs', blogsRouter);3. Utility Commands
Check Environment
View debugging information about your local environment. useful for reporting issues.
express-tool infoUpdate CLI
Check for updates or self-update the CLI tool.
express-tool upgrade📂 Project Structure
A typical project created with @express-tool/cli looks like this:
my-express-app/
├── 🐳 .dockerignore
├── ⚙️ .env
├── ⚙️ eslint.config.mjs
├── 🐙 .github/ # CI/CD Workflows
├── 🙈 .gitignore
├── 💅 .prettierrc
├── 🐳 docker-compose.yml
├── 🐳 Dockerfile
├── 📦 package.json
├── 📘 README.md
├── 📐 tsconfig.json # (If TypeScript)
├── 🧪 vitest.config.ts
├── src/
│ ├── 📁 controllers/ # Route handlers
│ ├── 📁 middleware/ # Custom middleware (auth, validation, error)
│ ├── 📁 models/ # Database models (Mongoose schemas)
│ ├── 📁 routes/ # Route definitions
│ ├── 📁 utils/ # Utility functions and Logger
│ ├── 📄 index.ts # Application entry point
│ └── 📄 app.test.ts # App setup tests
└── prisma/ # (If Prisma selected)
└── 📄 schema.prisma💻 Local Development
If you want to contribute to the project or run it from source, please check out our Development Guide.
🤝 Contributing
Contributions are welcome! Please open an issue or submit a pull request on our GitHub Repository.
📄 License
MIT © Mustak Ahmed Khan
