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