SetMetadata function to create decorators
Sorikairox opened this issue · 5 comments
Sorikairox commented
Is your feature request related to a problem? Please describe.
If I want to set a controller/method metadata, for example with a Public
decorator, I have to create it as follows:
export const IS_PUBLIC_KEY = 'isPublic';
export const Public = () =>
(
// deno-lint-ignore ban-types
target: ControllerConstructor | Object,
propertyKey?: string | symbol,
// deno-lint-ignore no-explicit-any
descriptor?: TypedPropertyDescriptor<any>,
) => {
if (propertyKey && descriptor) {
MetadataHelper.setMetadata(
IS_PUBLIC_KEY,
true,
descriptor.value,
);
} else {
MetadataHelper.setMetadata(IS_PUBLIC_KEY, true, target);
}
};
This is way too verbose, especially when creating multiple decorators that only set metadata.
Describe the solution you'd like
We should create a SetMetadata
function to be used as follows:
export const IS_PUBLIC_KEY = 'isPublic';
export const Public = () => SetMetadata(IS_PUBLIC_KEY, true);
Niravprajapati1 commented
Can i work on this issue ?
Sorikairox commented
@Niravprajapati1 sure go ahead
Niravprajapati1 commented
where do i want to add this function?
Sorikairox commented
Probably somewhere near MetadataHelper
Niravprajapati1 commented
How can i make this function i am begginer so i need some help !