biud436/stingerloom

feat: add PipeTransform to function called createCustomParamDecorator

biud436 opened this issue · 0 comments

export function createCustomParamDecorator(
callback: HttpParamDecoratorCallback,
): (...args: any[]) => ParameterDecorator {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
return (...args: any[]): ParameterDecorator =>
(target, propertyKey, index) => {
const previousCallback = Reflect.getMetadata(
HTTP_PARAM_DECORATOR_TOKEN,
target,
propertyKey as string,
) as CustomParamDecoratorMetadata;
// 키가 중복되지 않도록 해야 합니다.
const uniqueKey = getParamDecoratorUniqueKey(
target,
propertyKey as string,
index,
);
// 매개변수 인덱스를 읽는 기능이 없기 때문에 기존의 메타데이터와 병합해야 합니다.
Reflect.defineMetadata(
HTTP_PARAM_DECORATOR_TOKEN,
{
...mergeCustomParamDecoractor(
previousCallback,
target,
propertyKey,
index,
callback,
),
},
target,
propertyKey as string,
);
};

We need to pass PipeTransform to the parameter of a function named createCustomParamDecorator.

the server core don't know actual parameter type because it is passed String type every from the query or param.