nestjs-telegraf/lib/decorators/telegraf-entity.decorator.ts

24 lines
509 B
TypeScript
Raw Normal View History

2020-03-19 16:54:34 +03:00
import { SetMetadata } from '@nestjs/common';
import { DECORATORS } from '../telegraf.constants';
export type TelegrafEntityEntity =
| string
| string[]
| RegExp
| RegExp[]
| Function;
export interface TelegrafEntityMetadata {
entity: TelegrafEntityEntity;
}
2020-03-19 16:54:34 +03:00
/**
* Entity handling.
* @param entity Entity name
*
* https://telegraf.js.org/#/?id=entity
*/
export function TelegrafEntity(entity: TelegrafEntityEntity): MethodDecorator {
2020-03-19 16:54:34 +03:00
return SetMetadata(DECORATORS.ENTITY, { entity });
}