MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / handler

Function handler

website/api/v1/query.ts:71–92  ·  view source on GitHub ↗
(req: any, res: any)

Source from the content-addressed store, hash-verified

69}
70
71export default async function handler(req: any, res: any) {
72 res.setHeader("Access-Control-Allow-Origin", "*");
73 res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
74 res.setHeader("Access-Control-Allow-Headers", "Content-Type");
75
76 if (req.method === "OPTIONS") {
77 return res.status(200).end();
78 }
79
80 try {
81 return await handleQuery(req, res);
82 } catch (err: unknown) {
83 const message = err instanceof Error ? err.message : "Unknown server error";
84 console.error("[query] unhandled error:", message);
85 return res.status(200).json({
86 status: "error",
87 error: "Signaling gateway failed to execute tunnel query.",
88 details: message,
89 message: "Open https://cgc.codes/explore in a browser tab and retry.",
90 });
91 }
92}
93
94async function handleQuery(req: any, res: any) {
95 const method = req.method;

Callers

nothing calls this directly

Calls 2

handleQueryFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected