nestjs-telegraf/lib/decorators/PipeContext.ts

19 lines
455 B
TypeScript
Raw Normal View History

2019-02-28 11:29:26 +03:00
import { Type } from '@nestjs/common'
import { ContextTransformer } from '../ContextTransformer'
import { addHandlerToStore } from './TelegramActionHandler'
export const PipeContext = <T>(transform: Type<ContextTransformer<T>>) => (
target: Object,
propertyKey: string,
parameterIndex: number,
) => {
addHandlerToStore(target, propertyKey, {
transformations: [
{
index: parameterIndex,
transform,
},
],
})
}