UNPKG

apigeelint

Version:

Node module and tool to lint a bundle for an Apigee API Proxy or sharedflow.

85 lines (73 loc) 2.35 kB
/* Copyright © 2019,2025-2026 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ const xpath = require("xpath"), ConfigElement = require("./ConfigElement.js"), debug = require("debug")("apigeelint:HTC"); class HTTPTargetConnection extends ConfigElement { constructor(element, parent) { super(element, parent); this.name = undefined; this.URL = undefined; } getName() { if (this.name == undefined) { const attr = xpath.select("//@name", this.element); this.name = (attr[0] && attr[0].value) || ""; } return this.name; } getType = () => this.element.tagName; getURL() { if (this.URL === undefined) { const doc = xpath.select("./URL", this.element); if (doc && doc[0]) { if (doc[0].childNodes && doc[0].childNodes[0]) { this.URL = doc[0].childNodes[0].nodeValue || ""; } else { this.URL = ""; } } } return this.URL; } getProperties() { if (!this.properties) { this.properties = {}; debug("HTTPTargetConnection.js getting properties"); const propsElements = xpath.select("./Properties", this.element); const propsNodeList = propsElements && propsElements[0]; if (propsNodeList?.childNodes) { const self = this; Array.from(propsNodeList.childNodes).forEach(function (prop) { if ( prop.childNodes && prop.childNodes[0] && prop.attributes && prop.attributes[0] ) { self.properties[prop.attributes[0].nodeValue] = prop.childNodes[0].nodeValue; } }); } } return this.properties; } // unsure if used summarize = () => ({ name: this.getName(), url: this.getURL(), }); } //Public module.exports = HTTPTargetConnection;