UNPKG

alapa

Version:

A cutting-edge web development framework designed to revolutionize the way developers build modern web applications.

41 lines (40 loc) 1.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OpenApiPath = OpenApiPath; /* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable @typescript-eslint/no-explicit-any */ require("reflect-metadata"); const entry_1 = require("./entry"); function OpenApiPath(route, properties) { return function (target, propertyKey) { // Ensure temporalCollections exists if (!entry_1.temporalCollections["routes"]) { entry_1.temporalCollections["routes"] = {}; } if (!entry_1.temporalCollections["generalTags"]) { entry_1.temporalCollections["generalTags"] = {}; } if (!entry_1.temporalCollections["routes"][route]) { entry_1.temporalCollections["routes"][route] = {}; } // Merge the provided properties into the temporal collection for the route Object.keys(properties).forEach((key) => { entry_1.temporalCollections["routes"][route][key] = properties[key]; }); // Log to inspect the target and ensure we're dealing with the prototype // Access the class constructor from the prototype const classConstructor = target.constructor; // Check if the class constructor (i.e., the class itself) has openApiTags if (classConstructor.openApiTags) { entry_1.temporalCollections["generalTags"][route] = classConstructor.openApiTags; } else { if (classConstructor.name != "Function") { entry_1.temporalCollections["generalTags"][route] = classConstructor.name; } else if (classConstructor.name == "Function") { entry_1.temporalCollections["generalTags"][route] = target.name; } } }; }