nestjs-telegraf/lib/decorators/pipe-context.decorator.ts

19 lines
426 B
TypeScript
Raw Normal View History

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