Skip to content

Hemn-Raqib-Aziz/ts-express-boilerplate

Repository files navigation

ts-express-boilerplate

This is a simple, minimal boilerplate for building APIs using TypeScript and Express with native ESM module support.
It includes unit and end-to-end testing out of the box, making it a great starting point for new projects or learning purposes.


✨ Features

  • Express.js + TypeScript (with ESM)
  • Typed API routes with DTOs (Data Transfer Objects)
  • Unit testing with Jest
  • End-to-End testing with Supertest
  • Hot-reloading during development
  • Simple, scalable, and easy-to-extend project structure

📂 Project Structure

src/ │ ├── mocks/ → Mocks for unit testing ├── tests/ → Unit tests for route handlers │ └── handlers/ │ ├── e2e/ → End-to-End tests (Supertest) ├── dtos/ → Data Transfer Objects (DTOs) ├── handlers/ → Route handlers (controller logic) ├── routes/ → Express routes (API endpoints) ├── types/ → Shared TypeScript types │ ├── createApp.ts → App factory (for testing & production) └── index.ts → Main application entry point


📦 Available Scripts

Command Purpose
npm run build Transpile TypeScript into JavaScript (dist/)
npm start Run the compiled app from dist/
npm run start:dev Start in development mode with hot reload
npm test Run all tests (unit + E2E)
npm run test:e2e Run only End-to-End tests

🛠️ Running the Project Locally

1. Install Dependencies

npm install
2. Build the Project (Transpile TypeScript → JavaScript)
npm run build
3. Start the Compiled App
npm start
✅ Development Mode (No Build Needed)
Run the app in development with hot reload and TypeScript:

npm run start:dev
✅ Running Tests
All Tests:
npm test
E2E Tests Only:
npm run test:e2e
⚠️ Requirements
Node.js v18 or higher (for native ESM support)

ℹ️ Notes
This project is designed for educational purposes, testing, or as a lightweight starting point for new TypeScript Express APIs.

🙋 About This Repo
This project was created to explore a clean, minimal API setup with TypeScript, ESM modules, and testing.
Feel free to fork or extend it for your own needs!

About

Minimal Express.js API boilerplate using TypeScript, ESM, and Jest testing (Unit & E2E ready).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published