UNPKG

@loopback/rest

Version:

Expose controllers as REST endpoints and route REST API requests to controller methods

38 lines • 1.59 kB
"use strict"; // Copyright IBM Corp. and LoopBack contributors 2019. All Rights Reserved. // Node module: @loopback/rest // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT Object.defineProperty(exports, "__esModule", { value: true }); exports.assignRouterSpec = assignRouterSpec; function assignRouterSpec(target, additions) { var _a, _b, _c; var _d; if (additions.components) { (_a = target.components) !== null && _a !== void 0 ? _a : (target.components = {}); for (const key in additions.components) { (_b = (_d = target.components)[key]) !== null && _b !== void 0 ? _b : (_d[key] = {}); Object.assign(target.components[key], additions.components[key]); } } for (const url in additions.paths) { if (!(url in target.paths)) target.paths[url] = {}; for (const verbOrKey in additions.paths[url]) { // routes registered earlier takes precedence if (verbOrKey in target.paths[url]) continue; target.paths[url][verbOrKey] = additions.paths[url][verbOrKey]; } } if (additions.tags && additions.tags.length > 0) { (_c = target.tags) !== null && _c !== void 0 ? _c : (target.tags = []); for (const tag of additions.tags) { // tags defined earlier take precedence if (target.tags.some(t => t.name === tag.name)) continue; target.tags.push(tag); } } } //# sourceMappingURL=router-spec.js.map