A modern Node.js API boilerplate using TypeScript, Express, ESLint, Prettier, Vitest, and tsx for development.
- TypeScript with strict type checking
- Express for HTTP server
- ESLint + Prettier for consistent code
- Vitest for unit and integration tests
- Husky + lint-staged for pre-commit checks
- Hot-reloading with
tsx --watch - Environment variables via
.envfile - Modular folder structure:
routes/→ API endpointscontrollers/→ HTTP request handlingservices/→ business logicmodels/→ data modelsmiddlewares/→ Express middlewaresutils/→ helperstypes/→ TypeScript global types__tests__/→ tests
npm install
PORT=3000
npm run dev
Server will start with hot-reloading on changes.
npm run build npm start
npm run lint # check ESLint npm run lint:fix # fix ESLint issues npm run format # format code with Prettier npm run format:check # check formatting
npm run test # Vitest in watch mode npm run test:run # run all tests once npm run test:ui # open Vitest UI npm run coverage # generate coverage report
src/ ├─ index.ts # Entry point ├─ routes/ # API routes ├─ controllers/ # HTTP logic ├─ services/ # Business logic ├─ models/ # Data models ├─ middlewares/ # Express middlewares ├─ utils/ # Helper functions ├─ types/ # Global TypeScript types └─ tests/ # Unit & integration tests