The new strongly typed decorator factory is great. I'm attempting to replace all instances where we were setting the metadata in our codebase, however I've run across an example that breaks the mold a bit.
import { SetMetadata, applyDecorators } from "@nestjs/common";
import { DECORATORS } from "@nestjs/swagger/dist/constants";
export const IS_PUBLIC_METADATA_KEY = "isPublic";
/**
* Public decorator to explicitly set public routes
* Inspired by: https://docs.nestjs.com/security/authorization#basic-rbac-implementation
*/
export const Public = () =>
applyDecorators(
SetMetadata(IS_PUBLIC_METADATA_KEY, true),
SetMetadata(DECORATORS.API_SECURITY, [IS_PUBLIC_METADATA_KEY]),
);
In this case I'm using the single decorator to set multiple pieces of metadata under the hood (the second one is a workaround to override the default security setting). I haven't been able to find a clean pattern to replicate this behavior with Reflector.createDecorator. Looking for any suggestions for how to address this.