UNPKG

reest

Version:

A library inspired by NestJS's elegance, specifically designed for efficient serverless API development on AWS Lambda. It streamlines the creation of microservices with automated Swagger documentation and enhanced decorator-based middleware support, makin

41 lines (36 loc) 951 B
import { ParameterOptions } from "../types/ParameterOptions"; import { returnType } from "../utils/ReturnType"; export function Param(paramName?: string, options?: ParameterOptions) { return function ( target: Object, propertyKey: string | symbol, parameterIndex: number ) { const parameter = Reflect.getMetadata( "design:paramtypes", target, propertyKey )[parameterIndex]; const metadataKey = `__routeParameters__${String(propertyKey)}`; const existingParameters = Reflect.getOwnMetadata(metadataKey, target, propertyKey) || []; existingParameters.push({ paramName, parameterIndex, type: "param", options: { ...options, schema: { ...options?.schema, type: returnType(parameter), }, }, }); Reflect.defineMetadata( metadataKey, existingParameters, target, propertyKey ); }; }