Skip to content

A production-ready Node.js + TypeScript API template featuring Express, Knex, Zod validation, and clean architecture. Designed for building scalable backend services with a clear separation of concerns.

Notifications You must be signed in to change notification settings

edwardgnt/node-ts-api-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node + TypeScript API Template

A production-ready Node.js + TypeScript API template featuring Express, Knex, Zod validation, and a clean layered architecture.
Designed for building scalable backend services with clear separation of concerns and a strong developer experience.


🚀 Features

  • Node.js + TypeScript - modern, strongly typed backend foundation
  • Express - minimal and flexible API routing
  • Knex.js - SQL query builder (supports MySQL, PostgreSQL, SQLite, and more)
  • Zod - schema validation + DTO enforcement
  • Clean Architecture
    • Routes
    • Controllers
    • Services
    • Repositories
    • DTOs
  • Environment variable support using dotenv
  • CORS enabled
  • Development server with ts-node-dev
  • Production build with TypeScript compiler

📂 Project Structure


src/
├─ app.ts
├─ server.ts
├─ db/
│ └─ knex.ts
├─ routes/
│ └─ example.routes.ts
├─ controllers/
│ └─ example.controller.ts
├─ services/
│ └─ example.service.ts
├─ repositories/
│ └─ example.repository.ts
├─ dtos/
│ └─ example.dto.ts
.env.example
tsconfig.json
package.json
.gitignore

🔹 Layer Responsibilities

Routes – define API endpoints
Controllers – handle HTTP requests/responses
Services – business logic
Repositories – database operations
DTOs – input validation using Zod


🛠 Installation

Clone this repository:

git clone https://github.com/edwardgnt/node-ts-api-template.git
cd node-ts-api-template

Install dependencies:
npm install

Copy environment file:
cp .env.example .env

Server runs at:
http://localhost:5001

Production Build:
npm run build npm start

Example Endpoint:
GET /api/example

Response: { "message": "Hello from the repository layer!" }

🧩 Tech Stack

Node.js TypeScript Express Knex MySQL Zod dotenv ts-node-dev

About

A production-ready Node.js + TypeScript API template featuring Express, Knex, Zod validation, and clean architecture. Designed for building scalable backend services with a clear separation of concerns.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published