nestjs-telegraf/lib/decorators/pipe-context.decorator.ts
2020-01-12 02:41:27 +03:00

19 lines
426 B
TypeScript

import { Type } from '@nestjs/common'
import { ContextTransformer } from '../interfaces'
import { addHandlerToStore } from './'
export const PipeContext = <T>(transform: Type<ContextTransformer<T>>) => (
target: Object,
propertyKey: string,
parameterIndex: number,
) => {
addHandlerToStore(target, propertyKey, {
transformations: [
{
index: parameterIndex,
transform,
},
],
})
}