Skip to Content

nestia

nestia is a ttsc-powered toolkit for NestJS  that turns your TypeScript controllers into type-safe SDKs, OpenAPI documents, E2E test scaffolding, and migration assets, generated at build time from the controller’s actual TypeScript signatures.

It builds on typia: every payload validator, every JSON serializer, every random fixture in a generated SDK uses typia’s compile-time transform. nestia shares the same ttsc plugin protocol and the same compilerOptions.plugins[] wiring.

Install

npm install -D ttsc typescript typia @nestia/core @nestia/sdk

That’s it. Both typia and @nestia/core ship the ttsc.plugin auto-discovery marker, so ttsc picks them up the moment they appear in dependencies / devDependencies, no compilerOptions.plugins[] entry needed.

Run ttsc --emit (or any ttsc / ttsx / unplugin bundler). The build replaces @nestia/core decorators with type-aware validators and serializers, and the nestia CLI consumes the same TypeScript types to generate SDKs and docs.

What it generates

A typical NestJS controller written for nestia:

import { TypedBody, TypedRoute } from "@nestia/core"; import { Controller } from "@nestjs/common"; @Controller("users") export class UserController { @TypedRoute.Post() async create(@TypedBody() body: IUser.ICreate): Promise<IUser> { return /* ... */; } }

Without any schema duplication you get:

  • Type-safe SDK: npx nestia sdk produces an npm-publishable client; await sdk.user.create(connection, body) is fully typed against the controller signature, including narrowed response types.
  • Swagger / OpenAPI: npx nestia swagger emits OpenAPI 3.1 (and Swagger 2.0) documents derived from the exact controller types, including typia tags (Format<"email">, Maximum<150>, …).
  • E2E test stubs: npx nestia e2e scaffolds Jest/E2E test files per route, calling the generated SDK.
  • Migration assets: npx nestia template, npx nestia setup. Bootstrap pipelines and Swagger-to-controller migration.

The runtime decorators (@TypedBody, @TypedRoute.*, @TypedParam, @TypedQuery, …) replace the standard NestJS pipes with typia-generated validators, 20,000× faster than class-validator according to nestia’s benchmarks, and impossible to drift from the type because there is no parallel schema.

Why ttsc

@nestia/core is a TypeScript compiler transformer (it rewrites decorator calls at compile time), and typia is too. Stock tsc does not run user transformers; ttsc is one of the supported hosts. Both packages are auto-discovered from package.json (no compilerOptions.plugins[] entry needed), ttsc resolves, builds, and caches each sidecar, then routes the TypeScript-Go AST through them in order.

The full pipeline runs everywhere ttsc owns compilation, ttsc --emit, ttsx, and every @ttsc/unplugin bundler adapter. One install; the transforms run wherever NestJS code is compiled. VS Code uses the same project config for TypeScript-Go and supported plugin diagnostics/actions, but editor integration does not rewrite emit.

Combine with other ttsc plugins

nestia + typia compose because both are typia-aware (they share the typia compiler host under the hood). They also compose with @ttsc/lint, @ttsc/banner, @ttsc/paths, and @ttsc/strip in the same compilerOptions.plugins[] array. For combining unrelated executable transform hosts, see Plugin protocol → Combining plugins from different vendors.

Reference

nestia ships on its own release schedule with extensive docs.

See also

Last updated on