@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, 06:00 UTC

main
ts 38 lines 1.32 KB
Raw
1 import * as Lambda from "@alchemy.run/aws/Lambda";
2 import * as Neon from "@alchemy.run/neon";
3 import * as Effect from "effect/Effect";
4 import * as FetchHttpClient from "effect/http/FetchHttpClient";
5 import * as HttpServerResponse from "effect/http/HttpServerResponse";
6 import * as Layer from "effect/Layer";
7 import * as Redacted from "effect/Redacted";
8 import { backendAuth, backendDataApi, backendGateway } from "./backend-resources.ts";
9
10 const bindings = Layer.mergeAll(
11 Neon.ConnectAuthHttp,
12 Neon.QueryDataApiHttp,
13 Neon.QueryAIGatewayHttp,
14 ).pipe(Layer.provide(FetchHttpClient.layer));
15
16 export default class BackendHttpLambda extends Lambda.Function<BackendHttpLambda>()(
17 "BackendHttpLambda",
18 {
19 main: import.meta.url,
20 functionUrl: true,
21 },
22 Effect.gen(function* () {
23 const auth = yield* Neon.ConnectAuth(backendAuth);
24 const data = yield* Neon.QueryDataApi(backendDataApi);
25 const ai = yield* Neon.QueryAIGateway(backendGateway);
26 return {
27 fetch: Effect.gen(function* () {
28 return yield* HttpServerResponse.json({
29 authUrl: yield* auth.baseUrl,
30 jwksUrl: yield* auth.jwksUrl,
31 dataUrl: yield* data.baseUrl,
32 aiUrl: yield* ai.baseUrl,
33 hasToken: Redacted.value(yield* ai.token).length > 0,
34 });
35 }),
36 };
37 }).pipe(Effect.provide(bindings)),
38 ) {}