Open source
Node.js + Express + Prisma
Layered Express API template with Prisma, TypeScript, and Docker. Repository, controller, route structure ready to clone.
View on GitHubProject structure
- prisma
- migrations
- 20260719040313_added_user_model
- migration_lock.toml
- schema.prisma
- scripts
- tsconfig.json
- src
- controllers
- authentication_controller.ts
- health_controller.ts
- docs
- registry.ts
- swagger.ts
- lib
- env.ts
- prisma.ts
- repositories
- authentication_repository.ts
- health_repository.ts
- routes
- authentication_route.ts
- health_routes.ts
- index.ts
- services
- authentication_services.ts
- utils
- datetime.ts
- jwt.ts
- app.ts
- server.ts
- .dockerignore
- .env.example
- .gitignore
- docker-compose.yml
- Dockerfile
- package.json
- README.md
- tsconfig.json
# 1. Clone the project and install dependencies
$ git clone https://github.com/Gazzel16/nodejs-express-prisma-template.git
$ cd nodejs-express-prisma-template && npm install
# 2. Configure env and generate Prisma client
$ cp .env.example .env
$ npx prisma generate
# 3. Start the API server
$ npm run dev
→ Health: http://localhost:3000/api/health
→ Swagger: http://localhost:3000/api/docs
✓ API ready — hit the health route and start building!
README
Open on GitHubNode.js + Express + Prisma + Docker Template (TypeScript)
Layered API template with repository → controller → route.
Structure
src/
repositories/ # database queries
controllers/ # status codes & response shaping
routes/ # API endpoints
lib/ # shared clients (Prisma)
prisma/
schema.prisma # database models
Quick start (local)
- Copy env and set local Postgres credentials:
cp .env.example .env
DATABASE_URL=postgresql://postgres:your_password@localhost:5432/node_js_practice_db?schema=public
- Install and generate Prisma client:
npm install
npx prisma generate
- Run the API (TypeScript via
tsx):
npm run dev
- Health check:
curl http://localhost:3000/api/health
Swagger UI: http://localhost:3000/api/docs
Expected when DB is up:
{
"status": "ok",
"database": "up",
"uptime": 12.34,
"timestamp": "2026-07-19T00:00:00.000Z"
}
If the database is unreachable, the same route returns 503 with "database": "down".
Full stack with Docker
docker compose up --build
API: http://localhost:3000/api/health
Scripts
| Script | Description |
|---|---|
npm run dev | Start with TypeScript watch (tsx) |
npm run build | Compile TypeScript to dist/ |
npm start | Start compiled production server |
npm run prisma:generate | Generate Prisma Client |
npm run prisma:migrate | Create/apply migrations (dev) |
npm run prisma:deploy | Apply migrations (prod/Docker) |