Hey There! π
π€Ύ that βοΈ button if you like this boilerplate.
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.
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
- π Modular Structure: Organized by feature for easy navigation and scalability
- π¨ Faster Execution with tsx: Rapid TypeScript execution with
tsx
and type checking withtsc
- π 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
For a visual guide, watch the video demo to see the setup and running of the project.
- Clone the repository:
git clone https://github.com/edwinhern/express-typescript-2024.git
- Navigate:
cd express-typescript-2024
- Install dependencies:
npm ci
- Create
.env
: Copy.env.template
to.env
- Update
.env
: Fill in necessary environment variables
- Development Mode:
npm run dev
- Building:
npm run build
- Production Mode: Set
.env
toNODE_ENV="production"
thennpm run build && npm run start
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!
βββ 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