This is a well-structured boilerplate for building RESTful APIs using Node.js, Express, and TypeScript with Drizzle ORM and PostgreSQL. The project is designed for scalability, maintainability, and ease of contribution.
- Node.js - JavaScript runtime
- Express.js - Web framework
- TypeScript - Type-safe JavaScript
- Drizzle ORM - SQL query builder and ORM
- PostgreSQL - Relational database
- Docker (Optional) - Containerized environment
- pnpm - Fast, disk-efficient package manager
├── src/
│ ├── config/ # Application configuration
│ ├── controllers/ # Handles request-response logic
│ ├── middlewares/ # Express middlewares
│ ├── db/ # Database configuration & migrations
│ │ ├── migrations/ # Database migrations
│ │ ├── schema.ts # Database schema using Drizzle ORM
│ ├── routes/ # API route definitions
│ │ ├── v1/ # Version 1 routes
│ │ ├── v2/ # Version 2 routes
│ ├── services/ # Business logic & reusable services
│ ├── utils/ # Utility functions & helpers
│ ├── types/ # Centralized types & interface
│ ├── validations/ # Schema validations
│ ├── app.ts # Express app configuration
│ ├── index.ts # Server entry point
│
├── .env.example # Sample environment variables
├── package.json # Dependencies & scripts
├── tsconfig.json # TypeScript configuration
├── docker-compose.yml # Docker setup for development
├── README.md # Documentation
-
Clone the repository:
git clone https://github.com/logicalHassan/express-postgres-boilerpate.git cd express-postgres-boilerpate -
Install dependencies:
pnpm install
-
Configure environment variables:
cp .env.example .env
-
Run database migrations:
pnpm run db:generate
-
Apply database migrations:
pnpm run db:push
-
Start the development server:
pnpm run dev
| Command | Description |
|---|---|
pnpm run dev |
Start development server with live reload |
pnpm run build |
Compile TypeScript files to JavaScript |
pnpm start |
Run the compiled JavaScript server |
pnpm run lint |
Lint TypeScript files using Biome.js |
pnpm run db:generate |
Run Drizzle ORM database migrations |
pnpm run db:push |
Apply Drizzle ORM database migrations |
pnpm run db:sync |
Run & Apply migrations |
pnpm run db:reset |
Reset database migrations |
pnpm run db:studio |
Start Drizzle Studio |
pnpm run db:seed |
Seed database |
pnpm run test |
Run unit tests |
docker-compose up --buildThis will spin up PostgreSQL and the application container.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch (
feature/your-feature-name). - Commit your changes with meaningful messages.
- Open a pull request.
This project is licensed under the MIT License.