create-expressify
v1.0.3
Published
CLI tool to scaffold production-ready Express backends
Maintainers
Readme
create-expressify
A CLI tool to scaffold production-ready Express.js backends with TypeScript in seconds.
Installation
# Using npx (recommended)
npx create-expressify my-app
# Using pnpm
pnpm create expressify my-app
# Using yarn
yarn create expressify my-app
# Using bun
bun create expressify my-appFeatures
Clean Code Patterns
- Global Error Handler - Centralized error handling middleware
- Custom Error Classes - 24+ pre-built error classes (BadRequest, NotFound, Unauthorized, etc.)
- Response Wrapper - Consistent API response format
- Async Handler - Automatic async/await error catching
- Request Validator - Zod-based request validation middleware
- Service Layer - Separation of business logic
- Request ID Tracking - UUID-based request tracing
- Graceful Shutdown - Clean server shutdown handling
- API Versioning -
/api/v1route structure - Constants File - HTTP status codes and error messages
- Type Definitions - TypeScript interfaces and types
Database Support
- PostgreSQL
- MySQL
- SQLite
- MongoDB
- None (no database)
ORM Options
- Prisma - Type-safe database client with migrations
- Drizzle - Lightweight TypeScript ORM
- None (raw queries)
Authentication
- JWT - JSON Web Token authentication
- Session - Session-based authentication with Redis
- None (no auth)
Add-ons
- Rate Limiting - Express rate limiter middleware
- Redis Caching - Singleton-based Redis client with helper methods
- GitHub Actions - CI/CD workflow configuration
Generated Project Structure
my-app/
├── src/
│ ├── config/
│ │ ├── env.ts # Environment validation (Zod)
│ │ └── constants.ts # HTTP status codes, error messages
│ ├── db/
│ │ └── index.ts # Database client
│ ├── errors/
│ │ └── index.ts # All error classes
│ ├── middleware/
│ │ ├── auth.ts # Authentication middleware
│ │ ├── errorHandler.ts # Global error handler
│ │ ├── asyncHandler.ts # Async wrapper
│ │ ├── validate.ts # Request validation
│ │ ├── requestId.ts # Request ID tracking
│ │ └── rateLimiter.ts # Rate limiting
│ ├── routes/
│ │ └── v1/
│ │ ├── index.ts # Route aggregator
│ │ ├── health.ts # Health check endpoint
│ │ └── auth.ts # Auth routes
│ ├── services/
│ │ └── auth.service.ts # Auth business logic
│ ├── utils/
│ │ ├── logger.ts # Pino logger
│ │ ├── response.ts # Response helpers
│ │ └── redis.ts # Redis singleton client
│ ├── app.ts # Express app setup
│ └── index.ts # Server entry point
├── prisma/
│ └── schema.prisma # Prisma schema (if selected)
├── .github/
│ └── workflows/
│ └── ci.yml # GitHub Actions CI
├── .env
├── .gitignore
├── .prettierrc
├── Dockerfile
├── docker-compose.yml
├── eslint.config.js
├── package.json
├── tsconfig.json
└── README.mdError Classes
The generated project includes comprehensive error classes:
| Error Class | Status Code | Use Case |
|-------------|-------------|----------|
| BadRequestError | 400 | Invalid request syntax |
| ValidationError | 400 | Request validation failed |
| UnauthorizedError | 401 | Missing/invalid authentication |
| InvalidCredentialsError | 401 | Wrong email/password |
| TokenExpiredError | 401 | JWT token expired |
| InvalidTokenError | 401 | Malformed token |
| ForbiddenError | 403 | Access denied |
| InsufficientPermissionsError | 403 | Missing permissions |
| NotFoundError | 404 | Resource not found |
| UserNotFoundError | 404 | User doesn't exist |
| ResourceNotFoundError | 404 | Generic resource not found |
| MethodNotAllowedError | 405 | HTTP method not supported |
| ConflictError | 409 | Resource conflict |
| DuplicateError | 409 | Duplicate entry |
| EmailAlreadyExistsError | 409 | Email taken |
| GoneError | 410 | Resource no longer available |
| PayloadTooLargeError | 413 | Request body too large |
| UnsupportedMediaTypeError | 415 | Content type not supported |
| UnprocessableEntityError | 422 | Semantic errors |
| TooManyRequestsError | 429 | Rate limit exceeded |
| InternalServerError | 500 | Unexpected server error |
| DatabaseError | 500 | Database operation failed |
| ExternalServiceError | 500 | Third-party service error |
| NotImplementedError | 501 | Feature not implemented |
| BadGatewayError | 502 | Upstream server error |
| ServiceUnavailableError | 503 | Server temporarily down |
| GatewayTimeoutError | 504 | Upstream timeout |
Redis Client
The generated Redis client is a singleton with built-in helper methods:
import { redis } from './utils/redis';
// Connect to Redis
await redis.connect();
// Cache operations
await redis.set('user:1', { name: 'John' }, 3600); // with TTL
const user = await redis.get<User>('user:1');
await redis.del('user:1');
// Check connection
const isHealthy = await redis.ping();
// Disconnect
await redis.disconnect();Requirements
- Node.js >= 18.0.0
License
MIT
