UNPKG

kibana-123

Version:

Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana strives to be easy to get started with, while also being flexible and powerful, just like Elastic

46 lines (37 loc) 925 B
const _ = require("lodash"); 'use strict'; /** * * @param name */ function Api(name) { this.globalRules = {}; this.endpoints = {}; this.name = name; } (function (cls) { cls.addGlobalAutocompleteRules = function (parentNode, rules) { this.globalRules[parentNode] = rules; }; cls.addEndpointDescription = function (endpoint, description) { if (this.endpoints[endpoint]) { throw new Error("endpoint [" + endpoint + "] is already registered"); } var copiedDescription = {}; _.extend(copiedDescription, description || {}); _.defaults(copiedDescription, { id: endpoint, patterns: [endpoint], methods: ['GET'] }); this.endpoints[endpoint] = copiedDescription; }; cls.asJson = function () { return { "name": this.name, "globals": this.globalRules, "endpoints": this.endpoints } }; }(Api.prototype)); module.exports = Api;