mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2024-12-25 23:44:39 +03:00
16 lines
530 B
TypeScript
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);
|
|
};
|
|
}
|