feat(feature-control): add standalone BFF with bootstrap, exposure telemetry and tests

This commit is contained in:
Daniel Arantes Loverde
2026-04-16 14:46:38 -03:00
parent 2bc70c7d2a
commit f8d2fb8eb7
5 changed files with 741 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import http from "node:http";
import { createRuntime, handleBootstrap, handleExposure, loadConfig, nowIso, writeJson } from "./core.mjs";
const PORT = Number(process.env.PORT || 8787);
const runtime = createRuntime(loadConfig(process.env));
const server = http.createServer(async (req, res) => {
const method = req.method || "GET";
const url = req.url || "/";
if (method === "GET" && url === "/health") {
return writeJson(res, 200, {
ok: true,
service: "feature-control-bff",
time: nowIso(),
cacheEntries: runtime.cache.size,
inFlight: runtime.inFlight.size
});
}
if (method === "POST" && url === "/feature-control/bootstrap") {
return handleBootstrap(req, res, runtime);
}
if (method === "POST" && url === "/feature-control/telemetry/exposure") {
return handleExposure(req, res, runtime);
}
return writeJson(res, 404, { ok: false, code: "NOT_FOUND", message: "Rota não encontrada" });
});
server.listen(PORT, () => {
console.log(`[feature-control-bff] listening on :${PORT}`);
});