A robust and modern boilerplate for building backend applications with Express.js, loaded with essential tools and configurations to jumpstart your development.
- Runtime: Bun - A fast all-in-one JavaScript runtime.
- Framework: Express.js - Fast, unopinionated, minimalist web framework for Node.js.
- Language: TypeScript - Typed superset of JavaScript.
- Database ORM: Drizzle ORM - Lightweight and type-safe ORM.
- Database: PostgreSQL (via Neon Serverless driver).
- Authentication: Better Auth - Comprehensive authentication library.
- Logging: Pino - Very low overhead Node.js logger.
- Validation: Zod - TypeScript-first schema declaration and validation library.
- Rate Limiting:
express-rate-limitpre-configured. - CORS: Configured for cross-origin resource sharing.
- Core: Bun, Express, TypeScript
- Data: Drizzle ORM, PostgreSQL (Neon)
- Auth: Better Auth
- Utilities: Zod, Dotenv, Pino
├── src
│ ├── controllers # Request handlers
│ ├── db # Database connection and schema
│ ├── lib # Shared libraries and configurations
│ ├── logger # Logging configuration
│ ├── middlewares # Express middlewares
│ ├── routes # API routes
│ ├── schemas # Zod schemas for validation
│ ├── types # TypeScript type definitions
│ └── utils # Utility functions
├── .env.example # Example environment variables
├── drizzle.config.ts# Drizzle kit configuration
└── package.json # Project dependencies and scripts-
Clone the repository:
git clone <repository-url> cd express-boilerplate
-
Install dependencies:
bun install
-
Environment Setup:
Copy the
.env.examplefile to.env:cp .env.example .env
Update the
.envfile with your credentials:PORT=8000 DATABASE_URL="your-database-connection-string" BETTER_AUTH_SECRET="your-secret" BETTER_AUTH_URL="http://localhost:8000" GOOGLE_CLIENT_ID="your-google-client-id" GOOGLE_CLIENT_SECRET="your-google-client-secret" WEB_URL="http://localhost:3000"
Development Mode:
This starts the server with hot-reloading enabled.
bun run devPush Schema Changes:
Push your Drizzle schema changes to the database.
bun run db:pushOpen Drizzle Studio:
Visual database management tool.
bun run db:studioThis project is licensed under the MIT License - see the LICENSE file for details.