create-express-di-ts
v1.0.1
Published
CLI to create Express applications with TypeScript and Dependency Injection
Maintainers
Readme
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 configurationGetting Started
Prerequisites
- Node.js (v14+)
- TypeScript (v5+)
- Express (v4+)
Installation
- 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- Install dependencies
npm install- Create a
.envfile based on the.env.example
cp .env.example .env- Start the development server
npm run devAvailable Scripts
npm run dev: Start the development servernpm run build: Build the projectnpm run start: Start the production servernpm run clean: Clean the dist directory
Adding new Features
Creating a new Route
- Define your service interface in
interfaces/ - Implement your servince in
services/ - Create a controller in
controllers/ - Create a route factory in
routes/ - Add the route to the server in
server.ts
