【发布时间】:2019-10-06 09:46:26
【问题描述】:
使用 NestJS,我们可以使用验证管道转换传入请求 @Body()。
同样,我希望使用 https://github.com/typestack/class-transformer classToPlain 转换我的回复。
这样我可以将字段值映射到响应格式,例如:
export class FoobarDto {
@Transform((money: ExchangeableMoney) => money.localValues)
public foobar: ExchangeableMoney;
}
在 NestJS 中实现这一点的惯用方法是什么?
【问题讨论】:
-
也许你可以使用拦截器。 docs.nestjs.com/interceptors
标签: javascript node.js typescript express nestjs