Skip to content

Production-ready Express.js boilerplate with TypeScript and Dependency Injection. Features strong typing, constructor-based DI, repository pattern, standardized API responses, and modular architecture for building scalable and testable Node.js applications.

Notifications You must be signed in to change notification settings

maykelxyz/express-DI-TS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express TypeScript Dependency Injection Boilerplate

A lightweight, scalable Express.js boilerplate with TypeScript and Dependency Injection that follows clean architecture principles.

Features

  • TypeScript support
  • Dependency Injection
  • Minimal setup
  • Confgiuration Management
  • Development ready

Project Structure

│   ├── config.ts                # Application configuration management
│   ├── controllers/             # HTTP request handlers
│   │   └── UserController.ts    # Example controller
│   ├── interfaces/              # TypeScript interfaces
│   │   ├── IDBRepository.ts     # Repository interface
│   │   └── IUserServices.ts     # Service interface
│   ├── main.ts                  # Application entry point
│   ├── repository/              # Data access layer
│   │   └── DBRepository.ts      # Database operations implementation
│   ├── routes/                  # Express routes as factory functions
│   │   └── UserRoutes.ts        # User-related routes
│   ├── server.ts                # Express server setup with DI container
│   └── services/                # Business logic layer
│       └── UserServices.ts      # User-related business logic
├── .env                         # Environment variables (not in repo)
├── .env.example                 # Environment variables template
├── package.json                 # Project dependencies
└── tsconfig.json                # TypeScript configuration

Getting Started

Prerequisites

  • Node.js (v14+)
  • TypeScript (v5+)
  • Express (v4+)

Installation

  1. Clone the repository
# Using npx (recommended)
npx create-express-di-ts my-app

# Using npm
npm init create-express-di-ts my-app

# Using yarn
yarn cr
  1. Install dependencies
npm install
  1. Create a .env file based on the .env.example
cp .env.example .env
  1. Start the development server
npm run dev

Available Scripts

  • npm run dev: Start the development server
  • npm run build: Build the project
  • npm run start: Start the production server
  • npm run clean: Clean the dist directory

Adding new Features

Creating a new Route

  1. Define your service interface in interfaces/
  2. Implement your servince in services/
  3. Create a controller in controllers/
  4. Create a route factory in routes/
  5. Add the route to the server in server.ts

About

Production-ready Express.js boilerplate with TypeScript and Dependency Injection. Features strong typing, constructor-based DI, repository pattern, standardized API responses, and modular architecture for building scalable and testable Node.js applications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published