This project serves as a boilerplate for creating professional Node REST APIs. It is built with Express.js and TypeScript, providing a scalable and maintainable architecture for rapid development.
This project structure 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
- 🔑 Code Quality Assurance: Husky and lint-staged for consistent quality
- ✅ 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
.
├── .dockerignore
├── .env
├── .env.template
├── .github/
│ ├── renovate.json
│ └── workflows/
│ ├── build.yml
│ ├── code-quality.yml
│ ├── docker-image.yml
│ └── test.yml
├── .gitignore
├── .husky/
│ ├── _/
│ │ ├── .gitignore
│ │ ├── applypatch-msg
│ │ ├── commit-msg
│ │ ├── h
│ │ ├── husky.sh
│ │ ├── post-applypatch
│ │ ├── post-checkout
│ │ ├── post-commit
│ │ ├── post-merge
│ │ ├── post-rewrite
│ │ └── ...
│ ├── pre-commit
│ └── pre-push
├── .nvmrc
├── .vscode/
│ ├── launch.json
│ └── settings.json
├── biome.json
├── Dockerfile
├── package.json
├── README.md
├── src/
│ ├── api/
│ │ └── ...
│ ├── api-docs/
│ │ ├── openAPIResponseBuilders.ts
│ │ ├── openAPIDocumentGenerator.ts
│ │ └── openAPIRouter.ts
│ ├── common/
│ │ ├── models/
│ │ │ └── serviceResponse.ts
│ │ └── utils/
│ │ ├── commonValidation.ts
│ │ └── httpHandlers.ts
│ ├── config/
│ │ ├── __tests__/
│ │ │ └── currentEnv.test.ts
│ │ └── currentEnv.ts
│ ├── index.ts
│ └── server.ts
├── tsconfig.json
└── vite.config.mts
- Clone the repository:
git clone https://github.com/preyan/node-ts-starter.git
- Navigate:
cd node-ts-starter
- 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