mirror of
https://github.com/ershisan99/db-studio.git
synced 2025-12-16 05:09:26 +00:00
add raw query endpoint
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import cors from "@elysiajs/cors";
|
||||
import { Elysia } from "elysia";
|
||||
import { Elysia, t } from "elysia";
|
||||
import postgres from "postgres";
|
||||
|
||||
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();
|
||||
},
|
||||
)
|
||||
.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())
|
||||
.listen(3000);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user