From bc9d3e3d3f5e9dbbf9efe57bb28ea239e526a796 Mon Sep 17 00:00:00 2001 From: Rizky Date: Mon, 29 Jan 2024 09:56:27 +0700 Subject: [PATCH] fix --- pkgs/api/_dbs.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pkgs/api/_dbs.ts b/pkgs/api/_dbs.ts index b9066c4..5291170 100644 --- a/pkgs/api/_dbs.ts +++ b/pkgs/api/_dbs.ts @@ -5,16 +5,17 @@ export const _ = { url: "/_dbs/:dbName/:action", async api(dbName: any, action?: string) { const { req, res } = apiContext(this); + if (typeof db !== "undefined") { + const body = req.params; - const body = req.params; - - try { - const result = await execQuery(body, db); - res.send(result); - } catch (e: any) { - res.sendStatus(500); - res.send(e.message); - console.error(e); + try { + const result = await execQuery(body, db); + res.send(result); + } catch (e: any) { + res.sendStatus(500); + res.send(e.message); + console.error(e); + } } }, };