west-js-app
v3.1.0
Published
A progressive CLI framework for building robust Express.js backends.
Maintainers
Readme
W E S T . J S
Scaffold production-ready Express 5 + TypeScript projects in seconds. Pick a database ORM, add Docker, and start building.
npx west-js-appWhy west.js?
Starting a new Express project means wiring up TypeScript, linting, testing, error handling, env config, and more — every single time. west.js does all of that in one command.
- Express 5 — native async error handling, no wrappers needed
- TypeScript — strict mode, path resolution, source maps
- Database — Prisma 7, Drizzle, or TypeORM with PostgreSQL, MySQL, or SQLite
- Docker — multi-stage Dockerfile + compose with DB health checks
- Testing — Jest + Supertest with real HTTP assertions
- Linting — ESLint flat config + Prettier, pre-commit hooks via Husky
- Deploy — Vercel config included out of the box
Quick Start
npx west-js-appFollow the interactive prompts — or skip them entirely:
npx west-js-app --yes --name my-api --database prisma --db-provider postgresql --dockerThen:
cd my-api
npm run devYour API is running at http://localhost:3000.
CLI Options
Usage: npx west-js-app [options]
Options:
--name <name> Project name (kebab-case)
--database <orm> prisma | drizzle | typeorm | none
--db-provider <db> postgresql | mysql | sqlite
--docker Enable Docker support
--no-docker Disable Docker support
--package-manager <pm> npm | pnpm | yarn
-y, --yes Skip all prompts, use defaults
-v, --version Show version
-h, --help Show helpWhat gets generated.
my-api/
├── src/
│ ├── app.ts # Express app setup (cors, helmet, middlewares)
│ ├── server.ts # Server entry point with graceful shutdown
│ ├── routes/
│ │ ├── health.ts # GET /health — liveness probe
│ │ └── example.ts # Example CRUD route
│ ├── middleware/
│ │ ├── error-handler.ts # Centralized error handling
│ │ ├── validate.ts # Zod request validation middleware
│ │ └── rate-limit.ts # express-rate-limit global limiter
│ ├── config/
│ │ └── env.ts # Type-safe env validation
│ └── lib/
│ ├── errors.ts # Custom error classes
│ └── logger.ts # Pino structured logger
├── tests/
│ ├── app.test.ts # App integration tests
│ └── example.test.ts # Route unit tests
├── .husky/
│ └── pre-commit # Runs lint-staged on commit
├── package.json
├── tsconfig.json
├── eslint.config.mjs
├── .prettierrc
├── jest.config.js
├── .gitignore
├── .env
├── .env.example
└── vercel.jsonScripts in Generated Project
| Script | Description |
| --------------------- | -------------------------- |
| npm run dev | Dev server with hot reload |
| npm run build | Compile TypeScript |
| npm start | Run production build |
| npm test | Run tests |
| npm run lint | Lint with ESLint |
| npm run format | Format with Prettier |
| npm run db:generate | Generate database client |
| npm run db:migrate | Run migrations (if DB) |
| npm run db:studio | Database GUI (if DB) |
When you add a database, extra files are generated:
# Prisma
├── prisma/
│ └── schema.prisma
├── prisma.config.ts
└── src/lib/prisma.ts
# Drizzle
├── drizzle.config.ts
└── src/db/
├── index.ts
└── schema.ts
# TypeORM
└── src/db/
├── data-source.ts
├── index.ts
└── entities/
└── user.tsWhen you enable Docker:
├── Dockerfile # Multi-stage production build
├── docker-compose.yml # App + database services
└── .dockerignoreEnvironment Variables
The generated src/config/env.ts validates all environment variables at startup with a clean, type-safe pattern:
// Auto-validates on boot — crashes fast if misconfigured
export const env = {
PORT: ...,
NODE_ENV: ...,
DATABASE_URL: ..., // only if a database is selected
RATE_LIMIT_WINDOW_MS: ...,
RATE_LIMIT_MAX: ...,
};The generated .env:
PORT=3000
NODE_ENV=development
DATABASE_URL=postgresql://user:password@localhost:5432/mydb?schema=public
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX=100🌐 API Endpoints (Generated)
| Method | Path | Description |
| -------- | ------------------- | ------------------------- |
| GET | / | Welcome message + version |
| GET | /health | Liveness probe |
| GET | /api/examples | List all examples |
| GET | /api/examples/:id | Get example by ID |
| POST | /api/examples | Create example |
| DELETE | /api/examples/:id | Delete example |
Git Hooks
A pre-commit hook via Husky runs lint-staged on every commit:
# pnpm projects
pnpm exec lint-staged
# npm/yarn projects
npx lint-stagedContributing
# Clone
git clone https://github.com/vishalvoid/west.js.git
cd west.js
# Install dependencies
pnpm install
# Run CLI tests
pnpm -F cli run test
# Build CLI
pnpm -F cli run build
# Try it locally
node packages/cli/dist/index.js --help📄 License
MIT © vishalvoid
Made with ❤️ by vishalvoid
⭐ Star the repo if this saved you time → west.js
