@opra/common
Version:
Opra common package
41 lines (40 loc) • 1.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpApi = void 0;
const index_js_1 = require("../../helpers/index.js");
const api_base_js_1 = require("../common/api-base.js");
const http_controller_js_1 = require("./http-controller.js");
/**
* @class HttpApi
*/
class HttpApi extends api_base_js_1.ApiBase {
constructor(init) {
super(init);
// noinspection JSUnusedGlobalSymbols
this._controllerReverseMap = new WeakMap();
this.transport = 'http';
this.controllers = new index_js_1.ResponsiveMap();
this.url = init.url;
}
findController(arg0) {
return http_controller_js_1.HttpController.prototype.findController.call(this, arg0);
}
findOperation(arg0, operationName) {
const controller = this.findController(arg0);
return controller?.operations.get(operationName);
}
toJSON(options) {
const schema = super.toJSON();
const out = {
...schema,
transport: this.transport,
url: this.url,
controllers: {},
};
for (const v of this.controllers.values()) {
out.controllers[v.name] = v.toJSON(options);
}
return out;
}
}
exports.HttpApi = HttpApi;