menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Programming News

>

Effect with Nestjs
source image

Medium

1M

read

266

img
dot

Image Credit: Medium

Effect with Nestjs

  • Effect enhances Typescript by providing custom types and functions inspired by Functional Programming in Framework like ZIO in Scala.
  • Effect try to solve real Typescript problems and miss in the standard library that can be used with OOP in NestJS.
  • Refactors a basic flow using Nest pattern to Effect in cat service.
  • Using Effect Schema to decode the newCat object by a given Schema Cat which automatically returns a ParseError if it fails.
  • An Effect is not actually run before we specify it to do so by using an Interceptor.
  • The code examples and source code are available in the article.
  • We can also implement a custom Pipe to validate the DTO using the Effect.
  • Developers can improve experience and maintainability using Effect in cat service.
  • It solves the problems of explicit error throwing and validation.
  • Interceptor can be used to properly run the Effect before returning value in NestJS app.

Read Full Article

like

16 Likes

For uninterrupted reading, download the app