feat(kernel): expõe rotas do Registry no Dashboard
- Adiciona ServiceRegistry no DashboardServer - Cria rotas /api/registry/services, /stats, /:id - Permite acessar serviços descobertos via API - Integração completa Registry -> Dashboard
This commit is contained in:
parent
1cf73f55ba
commit
1f23256032
|
|
@ -13,6 +13,7 @@ import { HealthMonitor } from '../core/HealthMonitor';
|
||||||
import { LogAggregator } from '../core/LogAggregator';
|
import { LogAggregator } from '../core/LogAggregator';
|
||||||
import { KernelWebSocket } from '../websocket/KernelWebSocket';
|
import { KernelWebSocket } from '../websocket/KernelWebSocket';
|
||||||
import { createKernelRoutes } from '../api/routes';
|
import { createKernelRoutes } from '../api/routes';
|
||||||
|
import { ServiceRegistry } from '../registry/ServiceRegistry';
|
||||||
|
|
||||||
export interface DashboardServerOptions {
|
export interface DashboardServerOptions {
|
||||||
port?: number;
|
port?: number;
|
||||||
|
|
@ -29,6 +30,7 @@ export class DashboardServer {
|
||||||
private processManager: ProcessManager,
|
private processManager: ProcessManager,
|
||||||
private healthMonitor: HealthMonitor,
|
private healthMonitor: HealthMonitor,
|
||||||
private logAggregator: LogAggregator,
|
private logAggregator: LogAggregator,
|
||||||
|
private serviceRegistry?: ServiceRegistry,
|
||||||
options: DashboardServerOptions = {}
|
options: DashboardServerOptions = {}
|
||||||
) {
|
) {
|
||||||
this.options = {
|
this.options = {
|
||||||
|
|
@ -104,6 +106,27 @@ export class DashboardServer {
|
||||||
);
|
);
|
||||||
this.app.use('/api/kernel', kernelRoutes);
|
this.app.use('/api/kernel', kernelRoutes);
|
||||||
|
|
||||||
|
// Rotas do Registry (se disponível)
|
||||||
|
if (this.serviceRegistry) {
|
||||||
|
this.app.get('/api/registry/services', (req: Request, res: Response) => {
|
||||||
|
const services = this.serviceRegistry!.getServices();
|
||||||
|
res.json({ success: true, data: services, timestamp: new Date() });
|
||||||
|
});
|
||||||
|
|
||||||
|
this.app.get('/api/registry/stats', (req: Request, res: Response) => {
|
||||||
|
const stats = this.serviceRegistry!.getStats();
|
||||||
|
res.json({ success: true, data: stats, timestamp: new Date() });
|
||||||
|
});
|
||||||
|
|
||||||
|
this.app.get('/api/registry/services/:id', (req: Request, res: Response) => {
|
||||||
|
const service = this.serviceRegistry!.getService(req.params.id);
|
||||||
|
if (!service) {
|
||||||
|
return res.status(404).json({ success: false, error: 'Serviço não encontrado' });
|
||||||
|
}
|
||||||
|
res.json({ success: true, data: service, timestamp: new Date() });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Serve dashboard HTML
|
// Serve dashboard HTML
|
||||||
// Suporte a ESM e CommonJS (build do Docker)
|
// Suporte a ESM e CommonJS (build do Docker)
|
||||||
const __dirname = (() => {
|
const __dirname = (() => {
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,7 @@ export class ArcadiaKernel {
|
||||||
this.processManager,
|
this.processManager,
|
||||||
this.healthMonitor,
|
this.healthMonitor,
|
||||||
this.logAggregator,
|
this.logAggregator,
|
||||||
|
this.serviceRegistry, // Passa o Registry pro Dashboard
|
||||||
{
|
{
|
||||||
port: this.options.dashboard.port,
|
port: this.options.dashboard.port,
|
||||||
host: this.options.dashboard.host,
|
host: this.options.dashboard.host,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue