π A production-ready Express.js boilerplate with TypeScript, Prisma, and PostgreSQL
- Express.js - Fast, unopinionated, minimalist web framework
- TypeScript - JavaScript with syntax for types
- Prisma - Next-generation ORM for Node.js and TypeScript
- PostgreSQL - Advanced open-source relational database
- Helmet - Secure Express apps with various HTTP headers
- CORS - Cross-Origin Resource Sharing middleware
- Rate Limiting - Basic rate-limiting middleware
- Express Basic Auth - Simple basic auth middleware
- Morgan - HTTP request logger
- Winston - Multi-transport async logging
- Prometheus - Monitoring and alerting toolkit
- Grafana Loki - Log aggregation system
- Jest - Delightful JavaScript Testing Framework
- ESLint - Pluggable linting utility
- Prettier - Opinionated code formatter
- Nodemon - Auto-reload during development
- Node.js (v18 or higher)
- PostgreSQL
- Redis (optional, for caching)
- Clone the repository:
git clone https://github.com/yourusername/the-express-boilerplate.git
cd the-express-boilerplate
- Install dependencies:
npm install
- Set up environment variables:
cp .env.development .env
- Start the development server:
npm run dev:start
βββ src/
β βββ __tests__/ # Test files
β βββ config/ # Configuration files
β βββ helpers/ # Helper functions and constants
β βββ loaders/ # Startup process modules
β βββ middleware/ # Custom middleware
β βββ routes/ # API routes
β βββ types/ # TypeScript type definitions
β βββ utils/ # Utility functions
β βββ bootstrap.ts # Application bootstrap
β βββ server.ts # Server entry point
βββ prisma/ # Prisma schema and migrations
βββ docker/ # Docker configuration files
npm run dev:start
- Start the development server with hot-reloadnpm run build
- Build the projectnpm run prod:start
- Start the production servernpm test
- Run tests
Create a .env
file in the root directory:
# Server
PORT=3000
NODE_ENV=development
# Database
DATABASE_URL="postgresql://user:password@localhost:5432/dbname"
# JWT
JWT_SECRET=your-secret-key
# Redis
REDIS_URL="redis://localhost:6379"
Build and run with Docker Compose:
docker-compose up --build
This boilerplate includes:
- Prometheus metrics at
/metrics
- Grafana Loki for log aggregation
- Response time monitoring
- Custom metrics support
Run tests with Jest:
npm test
Test files are located in src/__tests__/
This project is licensed under the ISC License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
For support, please open an issue in the GitHub repository.