Express MySQL TypeScript
Express REST API with MySQL, Prisma ORM, JWT authentication, Swagger docs, and Docker support.
Quick Start
npx tempora-cli init express-mysql my-appStack
- Express 4
- TypeScript 5
- Prisma 5
- MySQL 8
- mysql2
- JSON Web Tokens (jsonwebtoken)
- Swagger UI (swagger-ui-express + swagger-jsdoc)
- Docker + Docker Compose
- Node.js 20
Running with Docker (Recommended)
Docker is the easiest way to run this — it starts both the app and MySQL for you with one command.
Prerequisites
- Docker Desktop installed and running
Steps
# 1. Start everything (MySQL + app)
docker compose up
# 2. On first run only — run migrations in a second terminal
docker exec express_mysql_app pnpm prisma migrate dev --name init
# 3. Visit the API docs
open http://localhost:3000/api/docsTo stop everything:
docker compose downTo stop and wipe the database:
docker compose down -vRunning Locally (Without Docker)
Prerequisites
- Node.js 20+
- pnpm
- MySQL 8 running locally
pnpm install
cp .env.example .env
# Edit .env with your local MySQL credentials
pnpm prisma migrate dev --name init
pnpm devServer running at http://localhost:3000
API Docs (Swagger)
Once the server is running, visit:
http://localhost:3000/api/docsYou can test every endpoint directly from the browser — no extra tools needed.
Testing the API Manually
1. Sign up
curl -X POST http://localhost:3000/api/auth/signup \
-H "Content-Type: application/json" \
-d '{"name":"Jane","email":"jane@example.com","password":"secret123"}'Copy the token from the response.
2. Login
curl -X POST http://localhost:3000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"jane@example.com","password":"secret123"}'3. Create a Todo
curl -X POST http://localhost:3000/api/todos \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-d '{"title":"Buy groceries"}'4. Get all Todos
curl http://localhost:3000/api/todos \
-H "Authorization: Bearer YOUR_TOKEN_HERE"5. Update a Todo
curl -X PUT http://localhost:3000/api/todos/1 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-d '{"completed":true}'6. Delete a Todo
curl -X DELETE http://localhost:3000/api/todos/1 \
-H "Authorization: Bearer YOUR_TOKEN_HERE"API Routes
Auth
| Method | Route | Access |
|---|---|---|
| POST | /api/auth/signup | Public |
| POST | /api/auth/login | Public |
Todos
| Method | Route | Access |
|---|---|---|
| GET | /api/todos | Protected |
| POST | /api/todos | Protected |
| PUT | /api/todos/:id | Protected |
| DELETE | /api/todos/:id | Protected |
Environment Variables
See .env.example for all required variables.
Documentation: tempora.irbaye.com