@incoderashu/create-express-app
v1.1.0
Published
Scaffold production-ready Express.js backends with security, validation, and best practices baked in.
Maintainers
Readme
create-express-app
Scaffold production-ready Express.js backends with security, database options, testing, API documentation, Docker support, and best practices baked in.
Quick Start
npx @incoderashu/create-express-app my-api
cd my-api
npm run devOr install globally:
npm install -g @incoderashu/create-express-app
create-express-app my-apiInteractive Experience
$ npx @incoderashu/create-express-app my-api
⚡ Create Express App
◇ Choose your language
│ ❯ TypeScript
│ JavaScript
◇ Choose module system
│ ❯ ESM
│ CommonJS
◇ Choose database
│ ❯ PostgreSQL + Prisma
│ MongoDB + Mongoose
│ None
◇ Select features
│ ◉ Security
│ ◉ Validation
│ ◉ Testing
│ ◉ ESLint + Prettier
│ ◯ Swagger / OpenAPI
│ ◯ Docker
│ ◯ CRUD example
┌─ Configuration ──────────────────────────┐
│ TypeScript • ESM • PostgreSQL + Prisma │
│ Security • Validation • Testing │
│ ESLint + Prettier │
└──────────────────────────────────────────┘
◇ Create project?
│ ❯ Yes
✔ Project structure created
✔ Configuration generated
✔ Features configured
✔ Dependencies installed
✨ Done!
cd my-api
npm run dev
http://localhost:5000CLI Flags
Skip any prompt with flags for automated CI or non-interactive use:
| Flag | Description | Default |
| -------------------- | ------------------------------------------------------------ | --------------------- |
| --js | Use JavaScript | true |
| --ts | Use TypeScript | false |
| --cjs | Use CommonJS module system | true |
| --esm | Use ESM module system | false |
| --db <choice> | Database: none, mongo, postgres | mongo |
| --nodemon | Install nodemon for auto-reload | true |
| --no-nodemon | Skip nodemon | false |
| --tests | Add testing setup (Vitest + Supertest) | true (with --yes) |
| --no-tests | Skip testing setup | false |
| --docs <choice> | API documentation: none, swagger | none |
| --docker | Add Dockerfile and docker-compose.yml setup | false |
| --auth | Add JWT authentication (requires MongoDB or PostgreSQL) | false |
| --extras <list> | Comma-separated extras: security,validator,eslint-prettier,crud-sample,docker,auth | None |
| --all-extras | Enable all applicable extras | false |
| --install | Install dependencies after scaffolding | true |
| --no-install | Skip dependency installation | false |
| --yes, -y | Accept sensible defaults (JS, CJS, Mongo, nodemon, tests, security, install) | false |
| --help, -h | Show help message | |
| --version, -v | Show version number | |
Examples
# All defaults — JS, CJS, MongoDB, nodemon, testing, security
create-express-app my-api --yes
# TypeScript + ESM + PostgreSQL + Prisma + Auth + Swagger + Testing + Docker
create-express-app my-api --ts --esm --db=postgres --auth --docs=swagger --tests --docker --yes
# Minimal API without database or tests (CI usage)
create-express-app my-api --js --cjs --db=none --no-tests --no-install
# Custom extras with CommonJS, MongoDB, and Auth
create-express-app my-api --js --cjs --db=mongo --auth --extras validator,security,docker --no-installGenerated Project Structure
my-api/
├── src/
│ ├── config/
│ │ ├── db.js # MongoDB connection or Prisma client singleton
│ │ └── swagger.js # Swagger / OpenAPI spec (if docs enabled)
│ ├── controllers/
│ │ ├── health.controller.js
│ │ ├── items.controller.js # CRUD sample controller (if selected)
│ │ └── auth.controller.js # JWT Auth controller (if auth selected)
│ ├── middlewares/
│ │ ├── errorHandler.js # Centralized error handler
│ │ ├── notFound.js # 404 catch-all
│ │ ├── security.js # Helmet, rate-limit, HPP (if security selected)
│ │ └── auth.middleware.js# protect and authorize guards (if auth selected)
│ ├── models/ # Mongoose models (user.model.js, item.model.js)
│ ├── routes/
│ │ ├── index.js # Route aggregator
│ │ ├── health.routes.js # Health check route (with OpenAPI annotations)
│ │ ├── items.routes.js # CRUD sample routes (if selected)
│ │ └── auth.routes.js # Auth routes (/register, /login, /refresh, etc.)
│ ├── utils/
│ │ ├── asyncHandler.js # try/catch async wrapper
│ │ ├── token.js # JWT signing, verification, and SHA-256 hash
│ │ └── cookie-options.js # Centralized httpOnly cookie options
│ ├── app.js # Express app configuration & middleware
│ └── server.js # HTTP server entry point & DB bootstrap
├── prisma/
│ └── schema.prisma # Prisma schema (User, RefreshToken, Item models)
├── tests/
│ ├── health.test.js # Supertest route tests (if testing enabled)
│ ├── auth.test.js # Auth endpoints & token reuse tests (if auth + tests)
│ └── setup.js # Test environment & DB lifecycle hooks
├── Dockerfile # Multi-stage or production container build (if Docker selected)
├── .dockerignore
├── docker-compose.yml # Docker compose service definition (if Docker selected)
├── .env
├── .env.example
├── .gitignore
├── package.json
├── vitest.config.js # Test runner config (if testing enabled)
├── tsconfig.json # TypeScript config (if TS selected)
└── README.mdAvailable Scripts (generated project)
| Script | Description |
| ---------------------- | --------------------------------------------------- |
| npm run dev | Start development server (with auto-reload) |
| npm start | Start production server |
| npm test | Run test suite with Vitest (if testing enabled) |
| npm run test:watch | Run tests in interactive watch mode |
| npm run test:coverage| Generate test coverage report |
| npm run build | Compile TypeScript with tsc (TS only) |
| npm run docker:up | Build and start Docker containers (if Docker extra) |
| npm run docker:down | Stop Docker containers (if Docker extra) |
| npm run lint | Run ESLint (if ESLint extra selected) |
| npm run format | Run Prettier formatting (if extra selected) |
License
MIT
