n8n
Version:
n8n Workflow Automation Tool
25 lines • 1.2 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.Delete = exports.Patch = exports.Put = exports.Post = exports.Get = void 0;
const constants_1 = require("./constants");
const RouteFactory = (method) => (path, options = {}) => (target, handlerName) => {
var _a, _b, _c, _d;
const controllerClass = target.constructor;
const routes = ((_a = Reflect.getMetadata(constants_1.CONTROLLER_ROUTES, controllerClass)) !== null && _a !== void 0 ? _a : []);
routes.push({
method,
path,
middlewares: (_b = options.middlewares) !== null && _b !== void 0 ? _b : [],
handlerName: String(handlerName),
usesTemplates: (_c = options.usesTemplates) !== null && _c !== void 0 ? _c : false,
skipAuth: (_d = options.skipAuth) !== null && _d !== void 0 ? _d : false,
rateLimit: options.rateLimit,
});
Reflect.defineMetadata(constants_1.CONTROLLER_ROUTES, routes, controllerClass);
};
exports.Get = RouteFactory('get');
exports.Post = RouteFactory('post');
exports.Put = RouteFactory('put');
exports.Patch = RouteFactory('patch');
exports.Delete = RouteFactory('delete');
//# sourceMappingURL=Route.js.map
;