Skip to content

Commit d8b1a3a

Browse files
Merge pull request nestjs#10085 from ZanMinKian/zmj-optimize_class_serializer_interceptor
refactor(common): optimize `ClassSerializerInterceptor`
2 parents 3f7a740 + 164ed6f commit d8b1a3a

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

packages/common/serializer/class-serializer.interceptor.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,9 @@ export class ClassSerializerInterceptor implements NestInterceptor {
8686
protected getContextOptions(
8787
context: ExecutionContext,
8888
): ClassTransformOptions | undefined {
89-
return (
90-
this.reflectSerializeMetadata(context.getHandler()) ||
91-
this.reflectSerializeMetadata(context.getClass())
92-
);
93-
}
94-
95-
private reflectSerializeMetadata(
96-
obj: object | Function,
97-
): ClassTransformOptions | undefined {
98-
return this.reflector.get(CLASS_SERIALIZER_OPTIONS, obj);
89+
return this.reflector.getAllAndOverride(CLASS_SERIALIZER_OPTIONS, [
90+
context.getHandler(),
91+
context.getClass(),
92+
]);
9993
}
10094
}

0 commit comments

Comments
 (0)