Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nestia/core

Package Overview
Dependencies
Maintainers
1
Versions
439
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestia/core

Super-fast validation decorators of NestJS

  • 1.0.17
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Nestia Core Library

GitHub license npm version Downloads Build Status Guide Documents

Super-fast validation decorators for NestJS.

  • 15,000x faster request body validation
  • 10x 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 15,000x times 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 {
    /** 
     * Store a new content.
     * 
     * @param inupt Content to store
     * @returns Newly archived article
     */
    @TypedRoute.Post() // 10x faster and safer JSON.stringify()
    public async store(
        @TypedBody() input: IBbsArticle.IStore // super-fast validator
    ): Promise<IBbsArticle>; 
        // do not need DTO class definition, 
        // just fine with interface
}

Setup

Boilerplate Project

npx nestia start <directory>

Just run above command, then boilerplate project would be constructed.

Setup Wizard

# setup both @nestia/core and @nestia/sdk
npx nestia setup

# setup @nestia/core only
npx @nestia/core setup

Just type npx nestia setup, that's all.

If you've installed ttypescript during setup, you should compile @nestia/core utilization code through ttsc command, instead of tsc.

# COMPILE THROUGH TTYPESCRIPT
npx ttsc

# RUN TS-NODE WITH TTYPESCRIPT
npx ts-node -C ttypescript src/index.ts

Otherwise, you've chosen ts-patch, you can use original tsc command. However, ts-patch hacks node_modules/typescript source code. Also, whenever update typescript version, you've to run npm run prepare command repeatedly.

By the way, when using @nest/cli, you must just choose ts-patch.

# USE ORIGINAL TSC COMMAND
tsc
npx ts-node src/index.ts

# HOWEVER, WHENVER UPDATE
npm install --save-dev typescript@latest
npm run prepare

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 {
    /** 
     * Store a new content.
     * 
     * @param inupt Content to store
     * @returns Newly archived article
     */
    @TypedRoute.Put(":id") // 50x faster and safer JSON.stringify()
    public async store(
        @TypedParam("section", "string") section: string,
        @TypedParam("id", "uuid") id: string,
        @TypedBody() input: IBbsArticle.IUpdate // super-fast validator
    ): Promise<IBbsArticle.IContent>;
}

About detailed features, read Guide Documents

Keywords

FAQs

Package last updated on 16 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc