A modern Node.js TypeScript template with a well-organized folder structure and best practices.
- Node.js 22.x (LTS)
- pnpm (recommended) or npm
Instructions for installing dependencies and running the app locally.
# Install dependencies
pnpm install
# Run in development mode
pnpm run dev
# Build for production
pnpm run build
# Start production server
pnpm run startsrc/
├── config/ # Configuration files and environment variables
├── constants/ # Application constants and enums
├── middleware/ # Express/HTTP middleware functions
├── services/ # Business logic and service layer
├── shared/ # Shared utilities and helpers
├── types/ # TypeScript type definitions and interfaces
├── utils/ # Utility functions and helpers
└── index.ts # Application entry point
tests/ # Unit and integration tests
dist/ # Compiled JavaScript output (generated)
| Folder | Description |
|---|---|
config/ |
Environment configuration, app settings, and external service configs |
constants/ |
Static values, HTTP status codes, error messages, and app-wide constants |
middleware/ |
Request processing middleware (auth, logging, validation, etc.) |
services/ |
Business logic layer with reusable service modules |
shared/ |
Cross-cutting utilities shared across the application |
types/ |
TypeScript interfaces, types, and type guards |
utils/ |
Helper functions and utility modules |
| Script | Description |
|---|---|
dev |
Starts the app in development mode with live reloading |
build |
Compiles TypeScript to JavaScript (CJS and ESM) |
start |
Runs the compiled app |
test |
Runs unit tests |
test:cov |
Runs tests with coverage report |
lint |
Runs ESLint to check and fix code style |
format |
Formats code using Prettier |
The project uses path aliases for cleaner imports:
import { config } from '@/config';
import { HTTP_STATUS } from '@/constants';
import { getCurrentTimestamp } from '@/utils';Build and run the application using Docker:
docker build -t template-node-typescript .
docker run -p 8080:8080 template-node-typescript- Node.js - JavaScript runtime (v22 LTS)
- TypeScript - Typed superset of JavaScript
- Jest - Testing framework
- ESLint - Linting utility
- Prettier - Code formatter
This project is licensed under the MIT License - see the LICENSE file for details.