nestjs-telegraf/lib/decorators/PipeContext.ts
2019-02-28 10:29:26 +02:00

19 lines
455 B
TypeScript

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,
},
],
})
}