Skip to Content

NestJS

NestiaΒ  is the NestJS integration layer built on top of typia. It replaces the usual class-validator + @nestjs/swagger setup with decorators that read your TypeScript interfaces directly β€” no DTO classes, no decorator soup.

It ships four packages:

PackageWhat it does
@nestia/coreSuperfast NestJS decorators backed by typia (@TypedBody, @TypedRoute, @TypedQuery, …)
@nestia/sdkEvolved SDK and Swagger generators that read NestJS controllers and emit type-safe client code
@nestia/migrateSwagger β†’ NestJS scaffolding
nestiaCLI for the above

Minimal controller

import { Controller } from "@nestjs/common"; import { TypedBody, TypedRoute } from "@nestia/core"; import type { IBbsArticle } from "@bbs-api/structures/IBbsArticle"; @Controller("bbs/articles") export class BbsArticlesController { /** * Store a new content. * * @param input Content to store * @returns Newly archived article */ @TypedRoute.Post() // ~200x faster, type-safe JSON.stringify public async store( @TypedBody() input: IBbsArticle.IStore, // ~20,000x faster validator ): Promise<IBbsArticle> { /* … no DTO class. Plain interface works. */ } }

The decorators are interchangeable with the standard NestJS ones β€” same shape, same testing approach, much less boilerplate. @TypedBody validates with typia.assert and @TypedRoute serializes with typia.json.assertStringify.

Incremental adoption

You can add @TypedBody / @TypedRoute to a single route without touching the rest of the codebase. Specifically:

  • @TypedBody and @Body coexist on different routes of the same controller. Existing class-validator-decorated DTOs keep working; you migrate route by route.
  • The build still uses tsc β€” but it must be the ts-patch-patched tsc. Add the legacy setup (wizard or manual) once, and from then on your existing npm run build keeps the same shape. CI pipelines that run npm ci --ignore-scripts need an explicit npx ts-patch install after install β€” see the CI tip on the Legacy setup page.
  • @nestia/sdk runs alongside @nestjs/swagger during migration. The two generators emit different artifacts (typed client SDK vs Swagger JSON), so you can keep @nestjs/swagger until every controller is on @TypedRoute, then drop it.

SDK generation

@nestia/sdk reads the same controller files and emits a typed client SDK plus a Swagger document. The TypeScript types you wrote on the server become the request/response types on the client, automatically.

nestia-sdk-demo

  • Left: NestJS server code
  • Right: Client code using the generated SDK

Where to go next

Last updated on