@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 07:15 UTC

main
ts 21 lines 698 Bytes
Raw
1 import type { Hyperdrive } from "@cloudflare/workers-types";
2 import { Client } from "pg";
3
4 /**
5 * Async Worker that binds the Workers VPC Hyperdrive via
6 * `env: { HD: connection }` and runs a query through it.
7 */
8 export default {
9 async fetch(_request: Request, env: { HD: Hyperdrive }): Promise<Response> {
10 const client = new Client({ connectionString: env.HD.connectionString });
11 try {
12 await client.connect();
13 const result = await client.query("select 'through-vpc' as via");
14 return Response.json(result.rows[0]);
15 } catch (error) {
16 return new Response(String(error), { status: 500 });
17 } finally {
18 await client.end().catch(() => {});
19 }
20 },
21 };