prasi-api/pkgs/api/_dbs.ts

22 lines
510 B
TypeScript

import { apiContext } from "service-srv";
import { execQuery } from "utils/query";
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;
try {
const result = await execQuery(body, db);
res.send(result);
} catch (e: any) {
res.sendStatus(500);
res.send(e.message);
console.error(e);
}
}
},
};