nestjs-telegraf/lib/telegraf.metadata-accessor.ts

26 lines
756 B
TypeScript
Raw Normal View History

import { Injectable } from '@nestjs/common';
2020-03-19 16:21:35 +03:00
import { Reflector } from '@nestjs/core';
import {
UPDATE_LISTENER_METHOD_METADATA,
2020-12-26 16:11:09 +03:00
UPDATE_METADATA,
2020-12-26 16:24:38 +03:00
UPDATE_LISTENER_OPTIONS_METADATA,
} from './telegraf.constants';
import { ListenerMethod } from './enums';
2020-03-19 16:21:35 +03:00
@Injectable()
export class TelegrafMetadataAccessor {
constructor(private readonly reflector: Reflector) {}
isUpdate(target: Function): boolean {
return !!this.reflector.get(UPDATE_METADATA, target);
}
getListenerMethod(target: Function): ListenerMethod | undefined {
return this.reflector.get(UPDATE_LISTENER_METHOD_METADATA, target);
}
getListenerOptions(target: Function): unknown[] {
return this.reflector.get(UPDATE_LISTENER_OPTIONS_METADATA, target) || [];
}
2020-03-19 16:21:35 +03:00
}