An open API service indexing awesome lists of open source software.

https://github.com/edwinhern/express-typescript-2024

Express + TypeScript starter template
https://github.com/edwinhern/express-typescript-2024

bolierplate docker docker-compose exception-handling express express-docker-compose express-typescript express-typescript-boilerplate express-typescript-tutorial expresstypescript logging typescript vitest

Last synced: about 1 month ago
JSON representation

Express + TypeScript starter template

Awesome Lists containing this project

README

        

# ๐Ÿš€ Express TypeScript Boilerplate 2024

[![CI](https://github.com/edwinhern/express-typescript-2024/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/edwinhern/express-typescript-2024/actions/workflows/ci.yml)

```code
Hey There! ๐Ÿ™Œ
๐Ÿคพ that โญ๏ธ button if you like this boilerplate.
```

## ๐ŸŒŸ Introduction

Welcome to the Express TypeScript Boilerplate 2024 โ€“ a streamlined, efficient, and scalable foundation for building powerful backend services with modern tools and practices in Express.js and TypeScript.

## ๐Ÿ’ก Motivation

This boilerplate aims to:

- โœจ Reduce setup time for new projects
- ๐Ÿ“Š Ensure code consistency and quality
- โšก Facilitate rapid development
- ๐Ÿ›ก๏ธ Encourage best practices in security, testing, and performance

## ๐Ÿš€ Features

- ๐Ÿ“ Modular Structure: Organized by feature for easy navigation and scalability
- ๐Ÿ’จ Faster Execution with tsx: Rapid TypeScript execution with `tsx` and type checking with `tsc`
- ๐ŸŒ Stable Node Environment: Latest LTS Node version in `.nvmrc`
- ๐Ÿ”ง Simplified Environment Variables: Managed with Envalid
- ๐Ÿ”— Path Aliases: Cleaner code with shortcut imports
- ๐Ÿ”„ Renovate Integration: Automatic updates for dependencies
- ๐Ÿ”’ Security: Helmet for HTTP header security and CORS setup
- ๐Ÿ“Š Logging: Efficient logging with `pino-http`
- ๐Ÿงช Comprehensive Testing: Setup with Vitest and Supertest
- โœ… Unified Code Style: `Biomejs` for consistent coding standards
- ๐Ÿ“ƒ API Response Standardization: `ServiceResponse` class for consistent API responses
- ๐Ÿณ Docker Support: Ready for containerization and deployment
- ๐Ÿ“ Input Validation with Zod: Strongly typed request validation using `Zod`
- ๐Ÿงฉ Swagger UI: Interactive API documentation generated from Zod schemas

## ๐Ÿ› ๏ธ Getting Started

### Video Demo

For a visual guide, watch the [video demo](https://github.com/user-attachments/assets/b1698dac-d582-45a0-8d61-31131732b74e) 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-2024.git`
- Navigate: `cd express-typescript-2024`
- Install dependencies: `npm ci`

#### 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: `npm run dev`
- Building: `npm run build`
- Production Mode: Set `.env` to `NODE_ENV="production"` then `npm run build && npm run start`

## ๐Ÿค 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

```code
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ biome.json
โ”œโ”€โ”€ package-lock.json
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ 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

14 directories, 31 files
```