A modern, production-ready boilerplate for building RESTful APIs with Express.js V5 and TypeScript.
- Latest Tech Stack: Built with Express V5 and TypeScript.
- Database ORM: Prisma with PostgreSQL support.
- Caching: Redis integration using
ioredis. - Validation: Strict environment and request validation using Zod.
- API Documentation: Automatic API documentation generated with Scalar.
- Logging: High-performance logging with Pino.
- Security:
helmetfor HTTP header security.corsfor Cross-Origin Resource Sharing.express-rate-limitfor rate limiting.
- Authentication:
- JWT (JSON Web Tokens) strategies.
- OAuth2 integration via Passport (Google, Facebook, GitHub).
- Monitoring: Telegram bot integration for error reporting (
telegraf). - Scheduled Jobs:
node-cronfor running background tasks (e.g., database cleanup). - Tooling:
- Deployment: Ready for Vercel deployment with included configuration.
- Node.js: >= 22.21.1
- Package Manager: pnpm (recommended)
git clone <repository-url>
cd express_boilerplatepnpm install
# or
npm install
# or
bun installCopy the example environment file and configure your variables:
cp .env.example .envUpdate .env with your database credentials, Redis URL, and API keys.
Ensure you have a PostgreSQL database running, then apply migrations:
pnpm prisma:migrate
pnpm prisma:generateDevelopment Mode:
pnpm dev
# Runs with --watch using tsxProduction Build:
pnpm build
pnpm start| Script | Description |
|---|---|
pnpm dev |
Start the development server with hot reload |
pnpm build |
Build the project for production using SWC |
pnpm start |
Run the built production server |
pnpm clean |
Remove the dist directory |
pnpm format |
Format code using Biome |
pnpm lint |
Lint code using Biome |
pnpm check |
Check code for formatting and linting errors |
pnpm prisma:migrate |
Run Prisma migrations |
pnpm prisma:studio |
Open Prisma Studio to view database |
├── .github/ # GitHub Actions workflows
├── src/
│ ├── configs/ # Configuration files (DB, Env, Logger, etc.)
│ ├── constants/ # Global constants
│ ├── core/ # Core application logic
│ ├── docs/ # API documentation setups
│ ├── middlewares/ # Express middlewares
│ ├── modules/ # Feature modules (Controllers, Services, Routes, Interfaces)
│ ├── prisma/ # Prisma schema and migrations
│ ├── utils/ # Utility helpers
│ ├── server.ts # Express app setup and middleware configuration
│ └── index.ts # Application entry point and server startup
├── types/ # Global type definitions
├── dist/ # Compiled output (ignored)
├── .env # Environment variables
├── tsconfig.json # TypeScript configuration
└── package.json # Dependencies and scripts
Key variables to configure in .env:
PORT: Server port (default: 6606)DATABASE_URL: PostgreSQL connection stringREDIS_URL: Redis connection stringJWT_ACCESS_SECRET: Secret for access tokensJWT_REFRESH_SECRET: Secret for refresh tokensTELE_BOT_TOKEN: Telegram Bot Token for alertsTELE_CHAT_ID: Telegram Chat ID for alertsDEBUG_CONSOLE: Enable console logging (default: true)DEBUG_FILE: Enable file logging (default: false)GOOGLE_CLIENT_ID: Google Client ID for OAuth2GOOGLE_CLIENT_SECRET: Google Client Secret for OAuth2FACEBOOK_APP_ID: Facebook App ID for OAuth2FACEBOOK_APP_SECRET: Facebook App Secret for OAuth2GITHUB_CLIENT_ID: GitHub Client ID for OAuth2GITHUB_CLIENT_SECRET: GitHub Client Secret for OAuth2
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the ISC License.