From bf8df60c02b9ddc7ba682809ca12c5637606393a Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Wed, 27 Mar 2024 13:19:28 -0700 Subject: [PATCH] move vector db debug endpoint to dev only --- server/index.js | 57 +++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/server/index.js b/server/index.js index 518df7fc8a..5b63cafa27 100644 --- a/server/index.js +++ b/server/index.js @@ -51,34 +51,6 @@ developerEndpoints(app, apiRouter); // Externally facing embedder endpoints embeddedEndpoints(apiRouter); -apiRouter.post("/v/:command", async (request, response) => { - try { - const VectorDb = getVectorDbClass(); - const { command } = request.params; - if (!Object.getOwnPropertyNames(VectorDb).includes(command)) { - response.status(500).json({ - message: "invalid interface command", - commands: Object.getOwnPropertyNames(VectorDb), - }); - return; - } - - try { - const body = reqBody(request); - const resBody = await VectorDb[command](body); - response.status(200).json({ ...resBody }); - } catch (e) { - // console.error(e) - console.error(JSON.stringify(e)); - response.status(500).json({ error: e.message }); - } - return; - } catch (e) { - console.log(e.message, e); - response.sendStatus(500).end(); - } -}); - if (process.env.NODE_ENV !== "development") { app.use( express.static(path.resolve(__dirname, "public"), { extensions: ["js"] }) @@ -92,6 +64,35 @@ if (process.env.NODE_ENV !== "development") { response.type("text/plain"); response.send("User-agent: *\nDisallow: /").end(); }); +} else { + // Debug route for development connections to vectorDBs + apiRouter.post("/v/:command", async (request, response) => { + try { + const VectorDb = getVectorDbClass(); + const { command } = request.params; + if (!Object.getOwnPropertyNames(VectorDb).includes(command)) { + response.status(500).json({ + message: "invalid interface command", + commands: Object.getOwnPropertyNames(VectorDb), + }); + return; + } + + try { + const body = reqBody(request); + const resBody = await VectorDb[command](body); + response.status(200).json({ ...resBody }); + } catch (e) { + // console.error(e) + console.error(JSON.stringify(e)); + response.status(500).json({ error: e.message }); + } + return; + } catch (e) { + console.log(e.message, e); + response.sendStatus(500).end(); + } + }); } app.all("*", function (_, response) {