const { proxyToApiServer } = require("../services/api-proxy");

// Routes already migrated to the separate Fastify API server (src/api/ +
// src/features/*/routes.ts) -- forwarded through rather than reimplemented
// inline a second time. All mechanically identical (proxyToApiServer(req,
// res, req.url)); handled as one data-driven dispatch instead of 12
// near-duplicate one-line route handlers.
const EXACT_PATHS = new Set([
  "/api/submarine-cables",
  "/api/global-infra",
  "/api/communities",
  "/api/irr-audit",
  "/api/asset-expand",
  "/api/rpki-history",
  "/api/aspath",
  "/api/looking-glass",
  "/api/ix-matrix",
  "/changelog-data",
  "/api/prefix-changes",
]);

function isProxyStubPath(reqPath) {
  return EXACT_PATHS.has(reqPath) || reqPath.startsWith("/api/rib/");
}

function handleProxyStub(req, res) {
  return proxyToApiServer(req, res, req.url);
}

module.exports = { isProxyStubPath, handleProxyStub };
