Back to templates

Open source

Node.js + Express + Prisma

Layered Express API template with Prisma, TypeScript, and Docker. Repository, controller, route structure ready to clone.

View on GitHub

Project 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
nodejs-express-prisma-template-terminal

# 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!

Node.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)

  1. 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
  1. Install and generate Prisma client:
npm install
npx prisma generate
  1. Run the API (TypeScript via tsx):
npm run dev
  1. 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

ScriptDescription
npm run devStart with TypeScript watch (tsx)
npm run buildCompile TypeScript to dist/
npm startStart compiled production server
npm run prisma:generateGenerate Prisma Client
npm run prisma:migrateCreate/apply migrations (dev)
npm run prisma:deployApply migrations (prod/Docker)