import { createLabHttpServer } from "./http.mjs";

const port = Number.parseInt(process.env.PORT ?? "8787", 10);
if (!Number.isInteger(port) || port < 0 || port > 65535) {
  throw new Error("PORT must be an integer between 0 and 65535.");
}

const { server } = createLabHttpServer();
server.listen(port, "127.0.0.1", () => {
  const address = server.address();
  const activePort = typeof address === "object" && address ? address.port : port;
  console.log(`Claims-denial teaching lab: http://127.0.0.1:${activePort}`);
  console.log("Local fixture tokens are documented in README.md; they are not secrets.");
});
