Express Typescript 2024 Save

Express + TypeScript + Boilerplate for Web / API App

Project README

๐Ÿš€ Express TypeScript Boilerplate 2024

Build Express Application CodeQL Docker Image CI Release

๐ŸŒŸ Introduction

Welcome to the Express TypeScript Boilerplate 2024 โ€“ a streamlined, efficient, and scalable foundation for building powerful backend services. This boilerplate merges modern tools and practices in Express.js and TypeScript, enhancing productivity, code quality, and performance.

๐Ÿ’ก Motivation and Intentions

Developed to streamline backend development, this boilerplate is your solution for:

  • โœจ Reducing setup time for new projects.
  • ๐Ÿ“Š Ensuring code consistency and quality.
  • โšก Facilitating rapid development with cutting-edge tools.
  • ๐Ÿ›ก๏ธ Encouraging 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 esbuild, complemented by tsc for type checking.
  • ๐ŸŒ Stable Node Environment: Latest LTS Node version in .nvmrc.
  • ๐Ÿ”ง Simplified Environment Variables with Envalid: Centralized and easy-to-manage configuration.
  • ๐Ÿ”— Path Aliases: Cleaner code with shortcut imports.
  • ๐Ÿ”„ Dependabot Integration: Automatic updates for secure and up-to-date dependencies.
  • ๐Ÿ”’ Security: Helmet for HTTP header security and CORS setup.
  • ๐Ÿ“Š Logging: Efficient logging with pino-http.
  • ๐Ÿงช Comprehensive Testing: Robust setup with Vitest and Supertest.
  • ๐Ÿ”‘ Code Quality Assurance: Husky and lint-staged for consistent quality.
  • โœ… Unified Code Style: ESLint and Prettier for a consistent coding standard.
  • ๐Ÿ“ƒ 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.
  • ๐Ÿงฉ API Spec Generation: Automated OpenAPI specification generation from Zod schemas to ensure up-to-date and accurate API documentation.

๐Ÿ› ๏ธ Getting Started

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

๐Ÿ“ Project Structure

.
โ”œโ”€โ”€ api
โ”‚   โ”œโ”€โ”€ healthCheck
โ”‚   โ”‚   โ”œโ”€โ”€ __tests__
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ healthCheckRouter.test.ts
โ”‚   โ”‚   โ””โ”€โ”€ healthCheckRouter.ts
โ”‚   โ””โ”€โ”€ user
โ”‚       โ”œโ”€โ”€ __tests__
โ”‚       โ”‚   โ”œโ”€โ”€ userRouter.test.ts
โ”‚       โ”‚   โ””โ”€โ”€ userService.test.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

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

Open Source Agenda is not affiliated with "Express Typescript 2024" Project. README Source: edwinhern/express-typescript-2024

Open Source Agenda Badge

Open Source Agenda Rating