Express Starter Foundation
The Express Starter Foundation is the core starting block provided by servercn. It provides a robust, production‑ready Express.js setup with sensible defaults, allowing you to focus on building features rather than boilerplate.
This foundation is not a framework; it's a well-structured boilerplate that you fully own and can extend as your project grows.
Installation Guide
To install the Express Starter Foundation, run the following command:
npx servercn-cli init express-starterWhat This Foundation Solves
Most Express projects require the same initial setup:
- Environment variable configuration & validation
- CORS and security headers
- Standardized API response and error formats
- TypeScript configuration
- Development tooling (hot reload, structured logging)
The Express Starter Foundation standardizes these concerns using battle-tested patterns.
Core Features
Regardless of the architecture you choose, you get these features out of the box:
Standard Response Format
All API responses follow a predictable structure, making frontend integration seamless:
Success Response:
Error Response:
Fast-Fail Environment Validation
Environment variables are validated at startup using Zod. If a required variable (like PORT or DATABASE_URL) is missing, the server will log a clear error and exit immediately, preventing runtime crashes.
Graceful Shutdown
The foundation includes logic to handle SIGINT and SIGTERM signals, ensuring that active requests are completed and database connections are closed properly before the process exits.
Extending the Foundation
The Express Starter Foundation is cumulative. Once initialized, you can easily add:
- Database Starters: Mongoose, Drizzle (MySQL/PostgreSQL)
- Auth Components: JWT Utilities, OAuth, RBAC
- Utility Components: Logger, File Upload, Email Service
Each component you add with servercn add will automatically align with your chosen architecture.
Summary
Use the Express Starter Foundation when:
- Starting a new production-ready Express API.
- You want a clean, typed foundation without the weight of a full framework.
- You need a consistent structure that scales with your team.