A production-ready Express.js backend boilerplate with comprehensive middleware setup, testing infrastructure, and best practices for security and performance.
- 🚀 Express.js with Node.js
- 🔒 Built-in security middleware (helmet, xss-clean, rate limiting)
- 📝 Swagger API documentation
- 🧪 Jest testing setup with coverage reporting
- 📝 Structured logging (Winston)
- 💾 In-memory caching with Cacheable
- 🗄️ Prisma ORM (v5.10.0) with database support
- ⚡️ Request monitoring with Morgan
- 🔍 ESLint + Prettier setup
- 🚦 PM2 process manager for production
- 🔐 JWT authentication with Passport
- 📧 Email support with Nodemailer
- 🌐 CORS enabled
- 🗜️ Response compression
- Clone this repository
- Copy
.env.templateto.envand update the values - Install dependencies:
npm install # or yarn install - Generate Prisma client:
npm run prisma:generate # or yarn prisma:generate - Push database schema:
npm run prisma:push # or yarn prisma:push - Start development server:
npm run dev # or yarn dev
├── src/ # Source code
├── prisma/ # Prisma configuration and schema
├── tests/ # Test files
├── .env.template # Environment variables template
├── ecosystem.config.json # PM2 configuration
├── jest.config.cjs # Jest configuration
├── .eslintrc.cjs # ESLint configuration
├── .prettierrc.cjs # Prettier configuration
└── babel.config.cjs # Babel configuration
yarn start: Start production server with PM2yarn dev: Start development server with hot reloadyarn test: Run testsyarn test:watch: Run tests in watch modeyarn coverage: Generate test coverage reportyarn lint: Run ESLintyarn lint:fix: Fix ESLint issuesyarn prettier: Check code formattingyarn prettier:fix: Fix code formattingyarn prisma:generate: Generate Prisma clientyarn prisma:push: Push schema changes to databaseyarn prisma:migrate: Create and apply migrationsyarn prisma:studio: Open Prisma Studio GUI
Required environment variables are documented in .env.template. Make sure to copy this file to .env and update the values accordingly.
The project uses JWT (JSON Web Tokens) with Passport.js for authentication. Protected routes can be implemented using the JWT strategy.
Built-in caching support using Cacheable provides:
- In-memory key-value storage with TTL
- Automatic cache invalidation
- Memory management
- Function result caching
Jest is configured for testing with:
- Coverage reporting
- Supertest for API testing
- Node-mocks-http for request/response mocking
- Faker for generating test data
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
MIT