mirror of
https://github.com/ershisan99/db-studio.git
synced 2025-12-16 12:33:05 +00:00
add raw query endpoint
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import cors from "@elysiajs/cors";
|
import cors from "@elysiajs/cors";
|
||||||
import { Elysia } from "elysia";
|
import { Elysia, t } from "elysia";
|
||||||
import postgres from "postgres";
|
import postgres from "postgres";
|
||||||
|
|
||||||
const DB_URL = Bun.env.DB_URL;
|
const DB_URL = Bun.env.DB_URL;
|
||||||
@@ -70,6 +70,19 @@ const app = new Elysia({ prefix: "/api" })
|
|||||||
return new Response(JSON.stringify(foreignKeys, null, 2)).json();
|
return new Response(JSON.stringify(foreignKeys, null, 2)).json();
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
.post(
|
||||||
|
"raw",
|
||||||
|
async ({ body }) => {
|
||||||
|
const { query } = body;
|
||||||
|
const result = await sql.unsafe(query);
|
||||||
|
return new Response(JSON.stringify(result, null, 2)).json();
|
||||||
|
},
|
||||||
|
{
|
||||||
|
body: t.Object({
|
||||||
|
query: t.String(),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
)
|
||||||
.use(cors())
|
.use(cors())
|
||||||
.listen(3000);
|
.listen(3000);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user