prasi-api/pkgs/api/_dbs.ts

22 lines
516 B
TypeScript

import { apiContext } from "service-srv";
import { execQuery } from "utils/query";
const g = global as any;
export const _ = {
url: "/_dbs/*",
async api() {
const { req, res } = apiContext(this);
if (typeof g.db !== "undefined") {
const body = req.params;
try {
const result = await execQuery(body, g.db);
res.send(result);
} catch (e: any) {
console.log("_dbs error", e.message);
res.sendStatus(500);
res.send(e.message);
}
}
},
};