Production-grade CLI for Express.js applications
npm install @express-tool/cliexpress-tool automates the boring setup, enforcing best practices, modern tooling, and clean architecture from day one.
npm, pnpm, yarn, and bun.
bash
npm install -g @express-tool/cli
`
$3
`bash
pnpm add -g @express-tool/cli
`
$3
`bash
yarn global add @express-tool/cli
`
$3
`bash
bun add -g @express-tool/cli
`
---
โก Execution without Installation
You can also execute the CLI instantly without installing it globally:
$3
`bash
npx @express-tool/cli init
`
$3
`bash
pnpm dlx @express-tool/cli init
`
$3
`bash
bunx @express-tool/cli init
`
---
๐ Usage
$3
The init command launches an interactive wizard to configure your new application.
`bash
express-tool init
`
Interactive Prompts:
1. Project Name: Name of your project directory (kebab-case).
2. Language: TypeScript (Recommended) or JavaScript.
3. Package Manager: Select npm, pnpm, yarn, or bun.
4. Architecture:
- Feature-based: Groups files by domain feature (e.g., src/modules/users/).
- MVC: Classic layering (src/controllers, src/routes, src/models).
5. API Type:
- REST API + Swagger: Includes setup for auto-generated API docs.
- REST API (Basic): Simple setup without documentation tools.
6. Database:
- PostgreSQL (Prisma)
- PostgreSQL (Prisma Postgres Managed)
- MySQL (Prisma)
- MongoDB (Mongoose)
- None
7. Authentication:
- JWT (JSON Web Token)
- None
8. Template Engine:
- EJS
- Pug
- None (API only)
9. Linting: (Yes/No) Include ESLint & Prettier.
10. Runtime Validation: (Yes/No) Include Zod.
---
$3
Quickly scaffold new resources (features) into your existing application. This command respects your project's language (TS/JS).
Syntax:
`bash
express-tool generate
or shorcut
express-tool g
`
Example:
`bash
express-tool g blogs
`
Output:
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):
`typescript
import { blogsRouter } from './routes/blogs.routes.js';
app.use('/blogs', blogsRouter);
`
---
$3
#### Check Environment
View debugging information about your local environment. useful for reporting issues.
`bash
express-tool info
`
#### Update CLI
Check for updates or self-update the CLI tool.
`bash
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
``