nestjs-telegraf/lib/helpers/create-update-decorator.helper.ts

16 lines
530 B
TypeScript

import { SetMetadata } from '@nestjs/common';
import { UpdateMethodArgs, UpdateMethods } from '../telegraf.types';
import { UPDATE_LISTENER_METADATA } from '../telegraf.constants';
import { ListenerMetadata } from '../interfaces/listener-metadata.interface';
export function createUpdateDecorator<Method extends UpdateMethods>(
method: Method,
) {
return (...args: UpdateMethodArgs<Method>): MethodDecorator => {
return SetMetadata(UPDATE_LISTENER_METADATA, {
method,
args,
} as ListenerMetadata);
};
}