nestjs-telegraf/lib/decorators/telegraf-entity.decorator.ts
2020-03-19 18:20:07 +03:00

24 lines
509 B
TypeScript

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