t3-code-android-nightly/.repos/alchemy-effect/packages/alchemy/test/Neon/fixtures/backend-http-lambda.ts
Julius Marminge 6f9cea00ae
chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 13:22:30 -07:00

42 lines
1.3 KiB
TypeScript

import * as Lambda from "@/AWS/Lambda";
import * as Neon from "@/Neon";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import * as Redacted from "effect/Redacted";
import * as FetchHttpClient from "effect/http/FetchHttpClient";
import * as HttpServerResponse from "effect/http/HttpServerResponse";
import {
backendAuth,
backendDataApi,
backendGateway,
} from "./backend-resources.ts";
const bindings = Layer.mergeAll(
Neon.ConnectAuthHttp,
Neon.QueryDataApiHttp,
Neon.QueryAIGatewayHttp,
).pipe(Layer.provide(FetchHttpClient.layer));
export default class BackendHttpLambda extends Lambda.Function<BackendHttpLambda>()(
"BackendHttpLambda",
{
main: import.meta.url,
functionUrl: true,
},
Effect.gen(function* () {
const auth = yield* Neon.ConnectAuth(backendAuth);
const data = yield* Neon.QueryDataApi(backendDataApi);
const ai = yield* Neon.QueryAIGateway(backendGateway);
return {
fetch: Effect.gen(function* () {
return yield* HttpServerResponse.json({
authUrl: yield* auth.baseUrl,
jwksUrl: yield* auth.jwksUrl,
dataUrl: yield* data.baseUrl,
aiUrl: yield* ai.baseUrl,
hasToken: Redacted.value(yield* ai.token).length > 0,
});
}),
};
}).pipe(Effect.provide(bindings)),
) {}