A modern Node.js TypeScript scaffold with best practices, comprehensive testing, and developer-friendly tooling.
- 🚀 Modern TypeScript - Latest TypeScript with strict type checking
- 📦 ESM Support - Native ECMAScript modules
- 🛠️ Development Tools - Hot reload with tsx, debugging support
- ✅ Testing Suite - Vitest with coverage reporting and UI
- 🎯 Code Quality - Biome for linting and formatting
- 🔧 Build System - TypeScript compiler with declaration files
- 📝 Logging - Structured logging with Pino
- ⚙️ Configuration - Environment validation with Zod
- 🔀 Git Hooks - Automated checks with Lefthook
- 🛡️ Error Handling - Custom error classes with correlation IDs
# Install dependencies
pnpm install
# Start development server
pnpm dev
# Run tests
pnpm test
# Build for production
pnpm build
# Start production server
pnpm startpnpm dev- Start development server with hot reloadpnpm dev:debug- Start with Node.js debugger enabled
pnpm test- Run tests once and exitpnpm test:watch- Run tests in watch modepnpm test:coverage- Run tests with coverage reportpnpm test:ui- Launch interactive test UI
pnpm lint- Lint code with Biomepnpm lint:fix- Lint and auto-fix issuespnpm format- Format code with Biomepnpm check- Run all Biome checkspnpm check:fix- Run checks with auto-fixpnpm typecheck- Type check with TypeScript
pnpm build- Compile TypeScript to JavaScriptpnpm start- Start production serverpnpm clean- Remove build artifacts
├── src/
│ ├── config/
│ │ └── env.ts # Environment configuration with Zod validation
│ ├── types/
│ │ └── common.ts # Shared TypeScript interfaces
│ ├── utils/
│ │ ├── errors.ts # Custom error classes
│ │ └── logger.ts # Structured logging setup
│ └── index.ts # Application entry point
├── test/ # Test files
├── dist/ # Compiled JavaScript output
└── coverage/ # Test coverage reports
The application validates environment variables using Zod schemas:
NODE_ENV- Environment mode (development,production,test)PORT- Server port (1-65535, default: 3000)LOG_LEVEL- Logging level (error,warn,info,debug)
TypeScript path aliases are configured for clean imports:
import { config } from '@/config/env';
import { logger } from '@/utils/logger';
import { AppError } from '@/utils/errors';Available aliases:
@/*→src/*@/types/*→src/types/*@/utils/*→src/utils/*@/config/*→src/config/*@/components/*→src/components/*@/middleware/*→src/middleware/*@/lib/*→src/lib/*@/constants/*→src/constants/*
Custom AppError class with correlation IDs and context:
// Factory methods for common error types
const error = AppError.validationError('Invalid input', { field: 'email' });
const error = AppError.notFoundError('User not found', { userId: 123 });
// Convert from standard Error
const appError = AppError.fromError(originalError, 400);Structured logging with Pino:
import { logger } from '@/utils/logger';
logger.info({ userId: 123 }, 'User logged in');
logger.error({ error: err.message, correlationId }, 'Database error');Type-safe environment configuration:
import { config } from '@/config/env';
console.log(config.NODE_ENV); // TypeScript knows this is a valid enum
console.log(config.PORT); // TypeScript knows this is a numberThe project includes comprehensive tests using Vitest:
- Unit Tests - All core utilities (errors, logger, config)
- Integration Tests - Application entry point and module imports
- Type Tests - TypeScript interface validation
- Coverage - 80% threshold for branches, functions, lines, statements
# Run all tests
pnpm test
# Run with coverage
pnpm test:coverage
# Watch mode for development
pnpm test:watch
# Interactive UI
pnpm test:uiLefthook manages Git hooks for code quality:
- Code formatting and linting (auto-fix enabled)
- TypeScript type checking
- Full test suite
- Production build verification
- Runtime - Node.js 20+
- Language - TypeScript 5.9
- Package Manager - pnpm
- Development - tsx (TypeScript execution)
- Testing - Vitest with V8 coverage
- Code Quality - Biome (ESLint + Prettier replacement)
- Logging - Pino with pretty printing
- Validation - Zod schemas
- Git Hooks - Lefthook
- Node.js ≥ 20.0.0
- pnpm ≥ 8.0.0
MIT
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and ensure they pass
- Submit a pull request
The project uses automated Git hooks to ensure code quality and test coverage.