@duongtrungnguyen/nestro
Version:
Service registry for Nest JS
88 lines • 3.42 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __decorateClass = (decorators, target, key, kind) => {
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
for (var i = decorators.length - 1, decorator; i >= 0; i--)
if (decorator = decorators[i])
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
if (kind && result) __defProp(target, key, result);
return result;
};
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
var dashboard_controller_exports = {};
__export(dashboard_controller_exports, {
DashboardController: () => DashboardController
});
module.exports = __toCommonJS(dashboard_controller_exports);
var import_common = require("@nestjs/common");
var import_services = require("../services");
let DashboardController = class {
constructor(registryService) {
this.registryService = registryService;
}
async renderDashboardUI() {
const services = await this.registryService.getServices();
return {
services,
hasServices: Object.keys(services).length > 0
};
}
async getServices() {
return this.registryService.getServices();
}
async getServicesByName(name) {
const services = await this.registryService.getServices(name);
return services[name] || [];
}
async deregisterService(name, host, port) {
await this.registryService.deregister({
name,
host,
port: parseInt(port, 10),
protocol: "http",
status: "ON"
});
return { success: true };
}
};
__decorateClass([
(0, import_common.Get)(),
(0, import_common.Render)("pages/dashboard")
], DashboardController.prototype, "renderDashboardUI", 1);
__decorateClass([
(0, import_common.Get)("api/services")
], DashboardController.prototype, "getServices", 1);
__decorateClass([
(0, import_common.Get)("api/services/:name"),
__decorateParam(0, (0, import_common.Param)("name"))
], DashboardController.prototype, "getServicesByName", 1);
__decorateClass([
(0, import_common.Delete)("api/services/:name/:host/:port"),
__decorateParam(0, (0, import_common.Param)("name")),
__decorateParam(1, (0, import_common.Param)("host")),
__decorateParam(2, (0, import_common.Param)("port"))
], DashboardController.prototype, "deregisterService", 1);
DashboardController = __decorateClass([
(0, import_common.Controller)("nestro/dashboard"),
__decorateParam(0, (0, import_common.Inject)(import_services.RegistryService))
], DashboardController);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
DashboardController
});
//# sourceMappingURL=dashboard.controller.js.map