UNPKG

@duongtrungnguyen/nestro

Version:
67 lines 2.27 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 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); import { Controller, Get, Delete, Param, Inject, Render } from "@nestjs/common"; import { RegistryService } from "../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([ Get(), Render("pages/dashboard") ], DashboardController.prototype, "renderDashboardUI", 1); __decorateClass([ Get("api/services") ], DashboardController.prototype, "getServices", 1); __decorateClass([ Get("api/services/:name"), __decorateParam(0, Param("name")) ], DashboardController.prototype, "getServicesByName", 1); __decorateClass([ Delete("api/services/:name/:host/:port"), __decorateParam(0, Param("name")), __decorateParam(1, Param("host")), __decorateParam(2, Param("port")) ], DashboardController.prototype, "deregisterService", 1); DashboardController = __decorateClass([ Controller("nestro/dashboard"), __decorateParam(0, Inject(RegistryService)) ], DashboardController); export { DashboardController }; //# sourceMappingURL=dashboard.controller.js.map