NestJS Fastify Starter Kit
Getting Started

Getting Started

Installation

  1. Install dependencies.
npm install
  1. Create a local environment file.
cp .env.example .env
  1. Run development mode.
npm run dev
  1. Open endpoints.
  • API Root: http://localhost:3000/
  • Swagger: http://localhost:3000/docs
  • Health: http://localhost:3000/health

Bootstrap With NPX

Scaffold a new project directly from this starter:

npx create-nest-fastify-app my-api

For package owner (one-time setup before global NPX usage):

npm login
npm publish --access public

Local test without publishing:

npm link
npx create-nest-fastify-app my-api

Starter cURL Commands

Quick smoke tests after running the server:

curl -X GET http://localhost:3000/
curl -X GET http://localhost:3000/health
curl -X GET http://localhost:3000/not-found

Available Scripts

ScriptDescription
npm run devStart in watch mode
npm run buildBuild to dist
npm run startStart app
npm run start:debugStart app in debug mode
npm run start:prodRun compiled output
npm run lintRun ESLint with autofix
npm run testRun unit tests
npm run test:e2eRun e2e tests

Project Structure

src/
  common/
    filters/
      http-exception.filter.ts
    interceptors/
      response.interceptor.ts
    pipes/
      request-validation.pipe.ts
  database/
    database.config.ts
    database.module.ts
    database.types.ts
    drizzle.provider.ts
  health/
    health.controller.ts
    health.module.ts
  utils/
    response/
      index.ts
      response-template.util.ts
  app.controller.ts
  app.module.ts
  app.service.ts
  main.ts