Nestia Core Library
Super-fast validation decorators for NestJS.
- 20,000x faster request body validation
- 200x faster JSON response, even type safe
- Do not need DTO class definition, just fine with interface
@nestia/core
is a transformer library of NestJS, supporting super-fast validation decorators, by wrapping typia. Comparing validation speed with class-validator
, typia is maximum 20,000x faster and it is even much safer.
Furthermore, @nestia/core
can use pure interface typed DTO with only one line. With @nestia/core
, you don't need any extra dedication like defining JSON schema (@nestjs/swagger
), or using class definition with decorator function calls (class-validator
). Just enjoy the superfast decorators with pure TypeScript type.
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 {
@TypedRoute.Post()
public async store(
@TypedBody() input: IBbsArticle.IStore
): Promise<IBbsArticle>;
}
Setup
Boilerplate Project
npx nestia start <directory>
Just run above command, then boilerplate project would be constructed.
Setup Wizard
npm install --save-dev nestia
npx nestia setup
Just type above two commands, that's all.
Manual Setup
If you want to install and configure @nestia/core
manually, read Guide Documents - Setup.
Features
import { Controller } from "@nestjs/common";
import { TypedBody, TypedRoute } from "@nestia/core";
import { IBbsArticle } from "@bbs-api/structures/IBbsArticle";
@Controller("bbs/articles")
export class BbsArticlesController {
@TypedRoute.Put(":id")
public async store(
@TypedParam("section", "string") section: string,
@TypedParam("id", "uuid") id: string,
@TypedBody() input: IBbsArticle.IUpdate
): Promise<IBbsArticle.IContent>;
}
About detailed features, read Guide Documents
- Decorators
- Enhancements
- Advanced Usage