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
| 1 | import * as agw2 from "@distilled.cloud/aws/apigatewayv2"; |
| 2 | import * as Output from "alchemy/Output"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | import * as Layer from "effect/Layer"; |
| 5 | import * as AWSBindings from "../AWSBindings.ts"; |
| 6 | import type { Api } from "./Api.ts"; |
| 7 | import { RegisterApiGatewayV2Binding } from "./BindingHttp.ts"; |
| 8 | import { ExportApi, type ExportApiRequest } from "./ExportApi.ts"; |
| 9 | |
| 10 | /** |
| 11 | * HTTP implementation of the {@link ExportApi} binding. Grants |
| 12 | * `apigateway:GET` on the API's `/exports/*` path and calls the API with |
| 13 | * the host Function's credentials. |
| 14 | */ |
| 15 | export const ExportApiHttp = Layer.effect( |
| 16 | ExportApi, |
| 17 | Effect.gen(function* () { |
| 18 | const registerApiGatewayV2Binding = yield* RegisterApiGatewayV2Binding; |
| 19 | const exportApi = yield* AWSBindings.withCredentials(agw2.exportApi); |
| 20 | return Effect.fn(function* <A extends Api>(api: A) { |
| 21 | const ApiId = yield* api.apiId; |
| 22 | yield* registerApiGatewayV2Binding({ |
| 23 | cap: "AWS.ApiGatewayV2.ExportApi", |
| 24 | target: api, |
| 25 | verb: "GET", |
| 26 | paths: (region) => [ |
| 27 | Output.interpolate`arn:aws:apigateway:${region}::/apis/${api.apiId}/exports/*`, |
| 28 | ], |
| 29 | }); |
| 30 | return Effect.fn(`AWS.ApiGatewayV2.ExportApi(${api.LogicalId})`)(function* ( |
| 31 | request?: ExportApiRequest, |
| 32 | ) { |
| 33 | return yield* exportApi({ |
| 34 | ...request, |
| 35 | ApiId: yield* ApiId, |
| 36 | Specification: request?.Specification ?? "OAS30", |
| 37 | }); |
| 38 | }); |
| 39 | }); |
| 40 | }), |
| 41 | ); |