Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Diving Into Design Metadata with NestJS

Diving Into Design Metadata with NestJS

Design-time metadata makes it possible to take advantage of features like reflection or dependency injection in JavaScript. Have you ever wondered how it is it possible that either Angular or NestJS automatically resolves relations between your classes? Or how can you access method param types to perform auto-validation of input parameters? Let's have an in-depth look at TypeScript metadata and see what we can achieve using this powerful mechanism.

Kamil Mysliwiec

October 20, 2019
Tweet

More Decks by Kamil Mysliwiec

Other Decks in Programming

Transcript

  1. KAMMYSLIWIEC interface ArgumentMetadata { type: 'body' | 'query' | 'param'

    | 'custom'; metatype?: Type<any>; data?: string; }
  2. KAMMYSLIWIEC @Post() async create( @Body() createDto: CreateRecipeDto, ): Promise<string> {

    return 'This action adds a new recipe'; } TYPE METATYPE DATA
  3. KAMMYSLIWIEC @Post() async create( @Body() createDto: CreateRecipeDto, ): Promise<string> {

    return 'This action adds a new recipe'; } TYPE METATYPE DATA