https://github.com/derek486/express-mysql-ts-starter
Express TypeScript Starter โ A structured and scalable boilerplate for building REST APIs with Express.js and TypeScript, featuring modular architecture, database integration, DTOs, error handling, and environment configuration. ๐
https://github.com/derek486/express-mysql-ts-starter
express mysql sequelize typescript
Last synced: about 2 months ago
JSON representation
Express TypeScript Starter โ A structured and scalable boilerplate for building REST APIs with Express.js and TypeScript, featuring modular architecture, database integration, DTOs, error handling, and environment configuration. ๐
- Host: GitHub
- URL: https://github.com/derek486/express-mysql-ts-starter
- Owner: Derek486
- License: mit
- Created: 2025-03-05T02:15:55.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-22T15:22:20.000Z (about 1 year ago)
- Last Synced: 2026-04-11T15:38:50.925Z (about 2 months ago)
- Topics: express, mysql, sequelize, typescript
- Language: TypeScript
- Homepage:
- Size: 19.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# **Express + TypeScript + MySQL Starter ๐**
A scalable, clean-architecture boilerplate for building RESTful APIs using **Express.js**, **TypeScript**, and **MySQL**. This project is ideal for developers who want a strong foundation with clear separation of concerns and modern development practices.
---
## **โจ Features**
โ
**TypeScript + Express** โ Fast, typed, and modern API development
โ
**Clean Architecture** โ Modular organization into HTTP, Infrastructure, Persistence, and Shared layers
โ
**MySQL + Sequelize ORM** โ Integrated with MySQL using Sequelize for models and migrations
โ
**Centralized Middleware** โ Auth, validation, and error-handling middlewares
โ
**Environment-Based Config** โ Easily configurable via `.env` files
โ
**Zod Validation** โ Lightweight schema validation for request bodies
โ
**Preconfigured Scripts** โ Dev and build/start scripts with migration support
---
## **๐ Project Structure**
```
express-mysql-ts-starter/
โ
โโโ .env # Environment variables
โโโ .env.example # Sample env file
โโโ .gitignore # Ignored files
โโโ package.json # Dependencies and scripts
โโโ tsconfig.json # TypeScript configuration
โ
โโโโsrc/
โโโ app.ts # Express app configuration
โโโ config.ts # Application-level config
โโโ index.ts # App entry point
โโโ migrate.ts # Manual migration runner
โ
โโโ http/ # HTTP layer
โ โโโ controllers/ # Controllers for each route
โ โโโ middlewares/ # Auth, validation, error middlewares
โ โโโ request/ # Request-specific types/schemas
โ โโโ shared/ # Codes and type helpers
โ
โโโ infrastructure/ # Business logic and app services
โ โโโ dto/ # Data Transfer Objects
โ โโโ implementation/ # Service implementations
โ โโโ mappers/ # Map entities <-> DTOs
โ โโโ repository/ # Abstraction for data access
โ โโโ shared/ # Common logic for infrastructure
โ
โโโ persistence/ # Database layer
โ โโโ migrations/ # Sequelize migration scripts
โ โโโ models/ # Sequelize models
โ โโโ connection.ts # DB connection setup
โ โโโ relations.ts # Table/model relationships
โ
โโโ routes/ # API route declarations
โโโ shared/ # App-wide utilities
```
---
## **๐ Getting Started**
### 1๏ธโฃ Install Dependencies
```bash
npm install
```
### 2๏ธโฃ Configure Environment Variables
Create a `.env` file (or copy from `.env.example`) and add your DB credentials:
```env
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=yourpassword
DB_NAME=express_ts_db
```
### 3๏ธโฃ Run Migrations
Run Sequelize migrations manually:
```bash
npm run migrate
```
### 4๏ธโฃ Run the Development Server
```bash
npm run dev
```
### 5๏ธโฃ Build and Run in Production
```bash
npm run build
npm start
```
---
## **๐งช Scripts Overview**
| Script | Purpose |
| ----------------- | --------------------------------------- |
| `npm run dev` | Start development server with `ts-node` |
| `npm run build` | Compile TypeScript into `dist/` |
| `npm start` | Run compiled app (requires `build`) |
| `npm run migrate` | Run migrations for development |
| `migrate:test` | Run migrations in test environment |
---
## **๐งโ๐ป Contributing**
Feel free to fork the repo and submit PRs or issues. Contributions are welcome! ๐ก
---
## **๐ Notes**
* Ensure MySQL is running and credentials in `.env` are valid.
* All requests are validated using `zod` in combination with `validator.middleware.ts`.
* The app uses JWT-based authentication (see `auth.middleware.ts`).
* Folder placeholders (`.gitkeep`) help keep the structure even if empty.
---
๐ฅ **Kickstart your next backend project with a scalable, modular architecture!** ๐