mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2025-09-30 04:18:51 +03:00
!feat(): use dynamic types for listener decorators
This commit is contained in:
15
lib/helpers/create-update-decorator.helper.ts
Normal file
15
lib/helpers/create-update-decorator.helper.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
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);
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user