import type { FastifyInstance } from "fastify"; import type { ThtRunner } from "../tht/tht-runner.js"; export function sqlRoutes(app: FastifyInstance, deps: { tht: ThtRunner }): void { app.post("/sessions/:id/sql/preview", async (req, reply) => { const id = (req.params as any).id as string; const { limit, offset } = (req.body as any) ?? {}; try { const result = await deps.tht.sqlPreview(id, { limit, offset }); return result; } catch (err: any) { return reply.code(500).send({ error: err.message ?? String(err) }); } }); app.post("/sessions/:id/sql/export", async (req, reply) => { const id = (req.params as any).id as string; try { const result = await deps.tht.sqlExport(id); return result; } catch (err: any) { return reply.code(500).send({ error: err.message ?? String(err) }); } }); }