Skip to content

kumarsonu676/node-express-prisma-starter-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

45 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Node Express Prisma Starter REST API

Node.js TypeScript Express Prisma PostgreSQL Docker JWT CI/CD License PRs Welcome

Production-ready REST API starter template built with Node.js, Express, and TypeScript. Features JWT authentication, PostgreSQL with Prisma ORM, Docker support, CI/CD pipeline, and best practices for scalable backend development.

Perfect for quickly bootstrapping new Node.js projects with enterprise-grade architecture.

Why This Starter?

  • πŸš€ Quick Start - Bootstrap your API in minutes
  • πŸ”’ Secure - JWT auth, helmet, rate limiting, input validation
  • 🐳 Docker Ready - Containerize with Docker & Docker Compose
  • βœ… Well Tested - Jest unit & integration tests
  • πŸ“š Documented - Swagger/OpenAPI docs out of the box
  • πŸ”§ Production Ready - Winston logging, error handling, graceful shutdown
  • πŸ’Ό Best Practices - Clean architecture, DI, code linting

Tech Stack

  • Runtime: Node.js 20.x
  • Framework: Express.js 5.x
  • Language: TypeScript (strict mode)
  • Database: PostgreSQL 14+ with Prisma ORM 7.x
  • Authentication: JWT (access + refresh tokens)
  • Validation: Zod
  • Dependency Injection: Inversify
  • Testing: Jest with ts-jest
  • Logging: Winston with file rotation
  • API Docs: Swagger/OpenAPI

Quick Start

Using Docker (Recommended)

# Clone the repo
git clone https://github.com/kumarsonu676/node-express-prisma-starter-rest-api.git
cd node-express-prisma-starter-rest-api

# Start with Docker
docker-compose up --build

Manual Setup

# Clone and install
git clone https://github.com/kumarsonu676/node-express-prisma-starter-rest-api.git
cd node-express-prisma-starter-rest-api
npm install

# Setup environment
cp .env.example .env

# Start PostgreSQL with Docker
docker run -d -p 5432:5432 -e POSTGRES_USER=app -e POSTGRES_PASSWORD=password -e POSTGRES_DB=app postgres:14

# Generate client & run migrations
npm run generate_prisma_client
npm run update_database

# Start development server
npm run dev

Server runs on http://localhost:3001

Features

Authentication & Authorization

  • JWT access + refresh token authentication
  • Role-based access control (RBAC)
  • Secure password hashing with bcrypt

API & Data

  • RESTful API design
  • Prisma ORM with PostgreSQL
  • Input validation with Zod
  • Swagger documentation at /api/docs

Security

  • Helmet.js for HTTP headers
  • Rate limiting
  • CORS configuration
  • Request ID tracking

Developer Experience

  • Hot reload with nodemon
  • TypeScript strict mode
  • Prettier code formatting
  • Commit message linting
  • Git hooks with Husky

Production Ready

  • Winston logging with rotation
  • Global error handling
  • Graceful shutdown
  • Docker multi-stage build

Available Scripts

Command Description
npm run dev Start development server
npm run build Compile TypeScript
npm run start Start production server
npm run test Run all tests
npm run test:watch Run tests in watch mode
npm run test:coverage Run tests with coverage
npm run format Format code with Prettier
npm run lint Check code formatting

Project Structure

src/
β”œβ”€β”€ config/              # App configuration, IoC container
β”œβ”€β”€ integrations/       # External services
β”‚   β”œβ”€β”€ notification/   # Email (SMTP)
β”‚   β”œβ”€β”€ payment/        # Stripe
β”‚   └── upload/         # Azure Blob Storage
β”œβ”€β”€ middleware/         # Express middleware
β”‚   β”œβ”€β”€ auth.middleware.ts
β”‚   β”œβ”€β”€ error.middleware.ts
β”‚   β”œβ”€β”€ validate.middleware.ts
β”‚   └── ...
β”œβ”€β”€ modules/            # Feature modules
β”‚   └── {module}/
β”‚       β”œβ”€β”€ {module}.controller.ts
β”‚       β”œβ”€β”€ {module}.service.ts
β”‚       β”œβ”€β”€ {module}.repository.ts
β”‚       β”œβ”€β”€ {module}.routes.ts
β”‚       β”œβ”€β”€ {module}.types.ts
β”‚       └── {module}.validation.ts
β”œβ”€β”€ routes/             # Route registration
β”œβ”€β”€ services/           # Shared services
β”œβ”€β”€ tests/             # Test files
β”œβ”€β”€ types/             # Global types
β”œβ”€β”€ utils/             # Utilities
└── app.ts             # Express app setup

API Documentation

Swagger docs available at: http://localhost:3001/api/docs

Authentication

Include tokens in Authorization header:

Authorization: Bearer <access_token>

Error Response Format

{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Human readable message"
  }
}

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for details.

License

ISC License - see LICENSE for details.

About

Production-ready REST API starter template built with Node.js, Express, and TypeScript. Features JWT authentication, PostgreSQL with Prisma ORM, Docker support, CI/CD pipeline, and best practices for scalable backend development. Perfect for quickly bootstrapping new Node.js projects with enterprise-grade architecture.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages