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

21 lines
641 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 {
TELEGRAF_LISTENER_TYPE,
TELEGRAF_MODULE_OPTIONS,
} from './telegraf.constants';
import { ListenerType } from './enums/listener-type.enum';
2020-03-19 16:21:35 +03:00
@Injectable()
export class TelegrafMetadataAccessor {
constructor(private readonly reflector: Reflector) {}
getListenerType(target: Function): ListenerType | undefined {
return this.reflector.get<ListenerType>(TELEGRAF_LISTENER_TYPE, target);
}
getListenerOptions<T>(target: Function): unknown | undefined {
return this.reflector.get<unknown>(TELEGRAF_MODULE_OPTIONS, target);
}
2020-03-19 16:21:35 +03:00
}