Scaffold Modern Express.js Apps in Seconds

An interactive CLI to generate a new project with a robust, scalable structure, your choice of database, and common middleware.

npx @alihussein/express-cli my-new-api

Why Use Express CLI?

Interactive Setup

An easy-to-use prompt guides you through the entire setup process.

Database Integration

Choose from MongoDB, PostgreSQL, or MySQL. The right dependencies and connection logic are configured for you.

Boilerplate Resources

Optionally include a pre-built User resource with a model, controller, and service layer.

Common Middleware

Automatically include JWT authentication, Morgan logging, and centralized error handling.

Modern JavaScript

Generates code using the latest ES Modules (import/export) syntax.

Scalable Architecture

Creates a clean, layered project structure that's easy to maintain and scale.

Installation

The recommended way to use the CLI is with `npx`, which ensures you are always using the latest version.

npx @alihussein/express-cli your-project-name

Alternatively, you can install it globally on your machine:

npm install -g @alihussein/express-cli

Usage

After running the command, the interactive setup will begin.

$ create-express-app my-new-api

? Which database would you like to use? (Use arrow keys)

❯ MongoDB

PostgreSQL

MySQL

? Would you like to include a boilerplate User resource? (Y/n)

? Which common middleware would you like to include? (Press <space> to select, <a> to toggle all, <i> to invert selection)

❯ ◉ Authentication (JWT)

◯ Request Logger (Morgan)

◉ Centralized Error Handling

Generated Project Structure

my-new-api/
├── .env
├── .gitignore
├── package.json
└── src/
    ├── app.js
    ├── index.js
    ├── config/
    │   └── db.js
    ├── constants.js
    ├── controllers/
    │   └── user.controller.js
    ├── middlewares/
    │   ├── auth.middleware.js
    │   └── error.middleware.js
    ├── models/
    │   └── user.model.js
    ├── routes/
    │   └── user.routes.js
    ├── services/
    │   └── user.service.js
    └── utils/
        ├── ApiError.js
        ├── ApiResponse.js
        └── asyncHandler.js