Serialization — Techniques · NestJS

Decide once, on the class, what leaves the server: exclude the microchip, expose a computed label, flatten the owner to a name, and apply the same rules to plain objects with SerializeOptions.

What you will learn

Read the theory for Serialization

All Techniques lessons

All NestJS courses

loading types…

What you'll learn

  • Register ClassSerializerInterceptor for the whole application and explain what instanceToPlain does to a handler's return value
  • Shape a response with @Exclude, @Expose on a getter and @Transform, restricted to the way out with toPlainOnly
  • Serialize plain objects by giving a route the class to treat them as, with @SerializeOptions({ type })