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

47 lines 1.89 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Query = void 0; const ReturnType_1 = require("../utils/ReturnType"); function Query(paramName, options) { return function (target, propertyKey, parameterIndex) { const parameter = Reflect.getMetadata("design:paramtypes", target, propertyKey)[parameterIndex]; const metadataKey = `__queryParameters__${String(propertyKey)}`; const existingParameters = Reflect.getOwnMetadata(metadataKey, target, propertyKey) || []; const parameterType = (0, ReturnType_1.returnType)(parameter); if (parameterType.type === "object") { Object.keys(parameterType.properties).forEach((key) => { const paramInfo = { isObject: true, type: "query", paramName: key, parameterIndex, options: { required: parameterType.required.includes(key), schema: { type: parameterType.properties[key].type, }, }, }; existingParameters.push(paramInfo); Reflect.defineMetadata(metadataKey, existingParameters, target, propertyKey); }); return; } const paramInfo = { type: "query", paramName, parameterIndex, options: { ...options, schema: { ...options?.schema, type: (0, ReturnType_1.returnType)(parameter), }, }, }; existingParameters.push(paramInfo); Reflect.defineMetadata(metadataKey, existingParameters, target, propertyKey); }; } exports.Query = Query; //# sourceMappingURL=Query.js.map