import { type CustomDecorator } from '@nestjs/common'; // implementation copied from SetMetadata, but tweaked to get existing values // of the metadataKey and accumulate it with the new metadataValue export function SetMultipleMetadata( metadataKey, metadataValue, ): CustomDecorator { const decoratorFactory: CustomDecorator = (target, key?, descriptor?) => { // .start: tweak // descriptor?.value = function decorator; target = class decorator const accumulatedVal = Reflect.getMetadata(metadataKey, descriptor?.value ?? target) ?? []; accumulatedVal.push(metadataValue); // .end: tweak if (descriptor) { Reflect.defineMetadata(metadataKey, accumulatedVal, descriptor.value); return descriptor; } Reflect.defineMetadata(metadataKey, accumulatedVal, target); return target; }; decoratorFactory.KEY = metadataKey; return decoratorFactory; }