feat: add l2 l3 simulator patch panel skeleton
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env node
|
||||
import { createGatewayState, createHealth } from "../../internal/sim/model.mjs";
|
||||
import { createJsonServer, listen, parsePort } from "../../internal/sim/http.mjs";
|
||||
|
||||
const gatewayId = process.env.HWLAB_GATEWAY_ID ?? "gwsimu_east";
|
||||
const port = parsePort(process.env.PORT, 7101);
|
||||
const endpoint = `http://127.0.0.1:${port}`;
|
||||
const boxes = (process.env.HWLAB_BOX_RESOURCES ?? "res_boxsim_alpha")
|
||||
.split(",")
|
||||
.map((item) => item.trim())
|
||||
.filter(Boolean);
|
||||
const state = createGatewayState({ gatewayId, endpoint, boxes });
|
||||
|
||||
const routes = new Map();
|
||||
|
||||
routes.set("GET /health/live", () =>
|
||||
createHealth({ serviceId: "hwlab-gateway-simu", name: gatewayId })
|
||||
);
|
||||
routes.set("GET /status", () => state);
|
||||
routes.set("GET /boxes", () => ({
|
||||
gatewayId,
|
||||
boxes: state.boxes
|
||||
}));
|
||||
|
||||
listen(createJsonServer({ routes }), port);
|
||||
Reference in New Issue
Block a user