Is it good idea to use decorators in high-load application?

67 Views Asked by At

We are building High load backend api in nestjs.

I am searching for good solution for rest request validation. We have some specific requirements for internationalization, so we decided not to use standard schema-based validation pipes, that does not handle internationalization well.

I am considering custom Mapper class for each request DTO. So it gets request data and transforms them into specific DTO: class CreateAccountRequestMapper { map(data: any): CreateAccountRequestDto {} } If the input is not valid, it will throw some API specific exception.

Is it good idea in terms of performance to implement this into decorators + pipes? I do not know the concept well, but it seems to me that I would need to make unnecessary object instantiation on each request, while if I would use the mapper directly in handler I would avoid it.

Do decorators means significant overhead in general?

0

There are 0 best solutions below