fix
This commit is contained in:
parent
1cca29d504
commit
0825b55d82
|
|
@ -1,20 +1,33 @@
|
|||
import { gunzipSync } from "bun";
|
||||
import { unpack } from "msgpackr";
|
||||
import { apiContext } from "service-srv";
|
||||
import { execQuery } from "utils/query";
|
||||
|
||||
const g = global as any;
|
||||
export const _ = {
|
||||
url: "/_dbs/*",
|
||||
raw: true,
|
||||
async api() {
|
||||
const { req, res } = apiContext(this);
|
||||
if (typeof g.db !== "undefined") {
|
||||
const body = req.params;
|
||||
if (req.params._ === "check") {
|
||||
return { mode: "encrypted" };
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await execQuery(body, g.db);
|
||||
return result;
|
||||
} catch (e: any) {
|
||||
console.log("_dbs error", body, e.message);
|
||||
const body = unpack(gunzipSync(await req.arrayBuffer()));
|
||||
|
||||
try {
|
||||
const result = await execQuery(body, g.db);
|
||||
return result;
|
||||
} catch (e: any) {
|
||||
console.log("_dbs error", body, e.message);
|
||||
res.sendStatus(500);
|
||||
res.send(e.message);
|
||||
}
|
||||
} catch (e) {
|
||||
res.sendStatus(500);
|
||||
res.send(e.message);
|
||||
res.send('{status: "unauthorized"}');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue