create-express-backend-kit
v1.0.3
Published
Scaffold a production-ready Express.js backend in seconds - folders, starter files, and all required libraries (helmet, cors, morgan, JWT auth, rate limiting, etc.) installed for you.
Maintainers
Readme
create-express-backend-kit
Scaffold a production-ready Express.js backend in one command: all folders, all starter files, and all required backend libraries installed for you.
npx create-express-backend-kit my-apiThat's it - you get a running Express API with security, validation, rate limiting, JWT auth, tests, and linting already wired up.
What you get
Folders & files created:
my-api/
├── src/
│ ├── config/env.js # centralized env loading & validation
│ ├── config/db.js # MySQL connection (mysql2 createConnection)
│ ├── controllers/auth.controller.js
│ ├── middleware/ # auth (JWT), validate, rateLimiter, errorHandler
│ ├── models/userStore.js # in-memory store, easy DB swap
│ ├── routes/ # index + auth routes
│ ├── utils/ # logger, ApiError, asyncHandler, jwt, password
│ ├── app.js # express app
│ └── server.js # http server + graceful shutdown
├── tests/auth.test.js # ready-to-run auth flow tests
├── .env / .env.example # with a generated JWT secret
├── eslint.config.js / .prettierrc.json / nodemon.json / .gitignore
└── package.json + README.mdLibraries installed automatically:
| Category | Packages |
| ----------------- | --------------------------------------------------------------- |
| Core | express |
| Database | mysql2 (createConnection, lazy connect, graceful close) |
| Security | helmet, cors, express-rate-limit |
| Auth | jsonwebtoken, bcryptjs |
| Utilities | morgan, dotenv, express-validator, compression |
| Dev | nodemon, eslint, prettier, cross-env |
Batteries included:
- Health check at
GET /health - Register / Login / Me endpoints with JWT auth
- Request validation (express-validator) and central JSON error handler
- Rate limiting (global + stricter on auth routes)
- Security headers (helmet), CORS whitelist via env var, gzip compression
- Structured JSON logging with levels
- MySQL connection ready out of the box (
src/config/db.js,query()helper) - Graceful shutdown (SIGINT/SIGTERM) that also closes the DB connection
- Working tests (
node:test) - no test framework config needed
Usage
# Interactive (asks project name / description / author)
npx create-express-backend-kit
# Non-interactive
npx create-express-backend-kit my-api --yes
# Options
npx create-express-backend-kit my-api --yes --git # also init git repo
npx create-express-backend-kit my-api --yes --no-install # skip npm installThen:
cd my-api
npm run devCLI options
| Flag | Description |
| -------------- | -------------------------------------------- |
| -y, --yes | Skip prompts, use defaults |
| --no-install | Don't run npm install after scaffolding |
| --git | Initialize a git repository in the project |
| -h, --help | Show help |
| -v, --version| Show version |
API endpoints included
| Method | Endpoint | Auth | Description |
| ------ | -------------------- | ---- | --------------------- |
| GET | /health | - | Health check |
| POST | /api/auth/register | - | Register, returns JWT |
| POST | /api/auth/login | - | Login, returns JWT |
| GET | /api/auth/me | JWT | Current user profile |
Try it:
curl -X POST http://localhost:3000/api/auth/register \
-H "Content-Type: application/json" \
-d '{"name":"Ada","email":"[email protected]","password":"supersecret1"}'Requirements
- Node.js >= 16
- npm
License
MIT
