A modular Express.js starter kit written in TypeScript. The project organizes features into self-contained modules that expose routes, middleware, and scheduled tasks while sharing common infrastructure.
- TypeScript-first setup with strict compiler configuration.
- Modular architecture: every module can register its own routes, middleware, and cron jobs.
- Dynamic loading of routes, middleware, and cron definitions at runtime.
- Security middleware via helmet and rate limiting on the
/apipath. - CORS configuration allowing cross-origin requests (adjustable for your domain).
- Static file serving with proper headers for large media files and range requests.
- Request timing middleware and reusable response handler for consistent API responses.
- Cron scheduling powered by node-cron.
- Node.js 18+
- npm
npm installnpm run devRuns the project with ts-node. Requests are served over HTTP on localhost.
npm run startThis command compiles TypeScript to the dist directory and starts the HTTPS server. When the DOMAIN environment variable is not localhost, it uses SSL certificates defined by PRIVKEY and FULLCHAIN.
npm run build– compile TypeScript without starting the server.npm test– execute Jest tests located undersrc/modules/**/tests.
| Variable | Description |
|---|---|
PORT |
Port number for the server (default: 3000). |
DOMAIN |
Host name. Use localhost for development. |
PRIVKEY |
Path to the SSL private key (production only). |
FULLCHAIN |
Path to the SSL certificate (production only). |
src/
├── config/ # Application and security configuration
├── contracts/ # Shared interfaces for modules
├── crons/ # Cron job registration
├── middleware/ # Global middleware and loader
├── modules/ # Feature modules (routes, middleware, crons)
└── utils/ # Shared utilities
Each module contains its own routes, middleware, crons, and optional tests.
npm testJest looks for test files under src/modules/**/tests.