Skip to content

edwinhern/express-typescript

Repository files navigation

πŸš€ Express TypeScript Boilerplate 2025

CI

Hey There! πŸ™Œ
🀾 that ⭐️ button if you like this boilerplate.

🌟 Introduction

Welcome to Express TypeScript Boilerplate 2025 – a simple and ready-to-use starting point for building backend web services with Express.js and TypeScript.

πŸ’‘ Why We Made This

This starter kit helps you:

  • ✨ Start new projects faster
  • πŸ“Š Write clean, consistent code
  • ⚑ Build things quickly
  • πŸ›‘οΈ Follow best practices for security and testing

πŸš€ What's Included

  • πŸ“ Well-organized folders: Files grouped by feature so you can find things easily
  • πŸ’¨ Fast development: Quick code running with tsx and error checking with tsc
  • 🌐 Latest Node.js: Uses the newest stable Node.js version from .tool-versions
  • πŸ”§ Safe settings: Environment settings checked with Zod to prevent errors
  • πŸ”— Short import paths: Clean code with easy imports using path shortcuts
  • πŸ”„ Auto-updates: Keeps dependencies up-to-date with Renovate
  • πŸ”’ Better security: Built-in protection with Helmet and CORS settings
  • πŸ“Š Easy tracking: Built-in logging with pino-http
  • πŸ§ͺ Ready-to-test: Testing tools with Vitest and Supertest already set up
  • βœ… Clean code: Consistent coding style with Biomejs
  • πŸ“ƒ Standard responses: Unified API responses using ServiceResponse
  • 🐳 Easy deployment: Ready for Docker containers
  • πŸ“ Input checking: Request validation using Zod
  • 🧩 API browser: Interactive API docs with Swagger UI

πŸ› οΈ Getting Started

Video Demo

For a visual guide, watch the video demo to see the setup and running of the project.

Step-by-Step Guide

Step 1: πŸš€ Initial Setup

  • Clone the repository: git clone https://github.com/edwinhern/express-typescript.git
  • Navigate: cd express-typescript
  • Install dependencies: pnpm install

Step 2: βš™οΈ Environment Configuration

  • Create .env: Copy .env.template to .env
  • Update .env: Fill in necessary environment variables

Step 3: πŸƒβ€β™‚οΈ Running the Project

  • Development Mode: pnpm start:dev
  • Building: pnpm build
  • Production Mode: Set NODE_ENV="production" in .env then pnpm build && pnpm start:prod

🀝 Feedback and Contributions

We'd love to hear your feedback and suggestions for further improvements. Feel free to contribute and join us in making backend development cleaner and faster!

πŸŽ‰ Happy coding!

πŸ“ Folder Structure

β”œβ”€β”€ biome.json
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ LICENSE
β”œβ”€β”€ package.json
β”œβ”€β”€ pnpm-lock.yaml
β”œβ”€β”€ README.md
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ api
β”‚   β”‚   β”œβ”€β”€ healthCheck
β”‚   β”‚   β”‚   β”œβ”€β”€ __tests__
β”‚   β”‚   β”‚   β”‚   └── healthCheckRouter.test.ts
β”‚   β”‚   β”‚   └── healthCheckRouter.ts
β”‚   β”‚   └── user
β”‚   β”‚       β”œβ”€β”€ __tests__
β”‚   β”‚       β”‚   β”œβ”€β”€ userRouter.test.ts
β”‚   β”‚       β”‚   └── userService.test.ts
β”‚   β”‚       β”œβ”€β”€ userController.ts
β”‚   β”‚       β”œβ”€β”€ userModel.ts
β”‚   β”‚       β”œβ”€β”€ userRepository.ts
β”‚   β”‚       β”œβ”€β”€ userRouter.ts
β”‚   β”‚       └── userService.ts
β”‚   β”œβ”€β”€ api-docs
β”‚   β”‚   β”œβ”€β”€ __tests__
β”‚   β”‚   β”‚   └── openAPIRouter.test.ts
β”‚   β”‚   β”œβ”€β”€ openAPIDocumentGenerator.ts
β”‚   β”‚   β”œβ”€β”€ openAPIResponseBuilders.ts
β”‚   β”‚   └── openAPIRouter.ts
β”‚   β”œβ”€β”€ common
β”‚   β”‚   β”œβ”€β”€ __tests__
β”‚   β”‚   β”‚   β”œβ”€β”€ errorHandler.test.ts
β”‚   β”‚   β”‚   └── requestLogger.test.ts
β”‚   β”‚   β”œβ”€β”€ middleware
β”‚   β”‚   β”‚   β”œβ”€β”€ errorHandler.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ rateLimiter.ts
β”‚   β”‚   β”‚   └── requestLogger.ts
β”‚   β”‚   β”œβ”€β”€ models
β”‚   β”‚   β”‚   └── serviceResponse.ts
β”‚   β”‚   └── utils
β”‚   β”‚       β”œβ”€β”€ commonValidation.ts
β”‚   β”‚       β”œβ”€β”€ envConfig.ts
β”‚   β”‚       └── httpHandlers.ts
β”‚   β”œβ”€β”€ index.ts
β”‚   └── server.ts
β”œβ”€β”€ tsconfig.json
└── vite.config.mts