This repository has been archived on 2026-03-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
openclaw-extensions/wecom/node_modules/@slack/bolt/dist/receivers/custom-routes.js
T

34 lines
1.4 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildReceiverRoutes = void 0;
const errors_1 = require("../errors");
function buildReceiverRoutes(customRoutes) {
const routes = {};
validateCustomRoutes(customRoutes);
for (const r of customRoutes) {
const methodObj = Array.isArray(r.method)
? // biome-ignore lint/performance/noAccumulatingSpread: TODO: apparently this is a perf hit?
r.method.reduce((o, key) => ({ ...o, [key.toUpperCase()]: r.handler }), {})
: { [r.method.toUpperCase()]: r.handler };
routes[r.path] = routes[r.path] ? { ...routes[r.path], ...methodObj } : methodObj;
}
return routes;
}
exports.buildReceiverRoutes = buildReceiverRoutes;
function validateCustomRoutes(customRoutes) {
const requiredKeys = ['path', 'method', 'handler'];
const missingKeys = [];
// Check for missing required keys
for (const route of customRoutes) {
for (const key of requiredKeys) {
if (route[key] === undefined && !missingKeys.includes(key)) {
missingKeys.push(key);
}
}
}
if (missingKeys.length > 0) {
const errorMsg = `One or more routes in customRoutes are missing required keys: ${missingKeys.join(', ')}`;
throw new errors_1.CustomRouteInitializationError(errorMsg);
}
}
//# sourceMappingURL=custom-routes.js.map