The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as AWS from "@alchemy.run/aws"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import { HttpServerRequest } from "effect/http/HttpServerRequest"; |
| 4 | import * as HttpServerResponse from "effect/http/HttpServerResponse"; |
| 5 | |
| 6 | /** A Lambda that reaches the AWS package through `import * as AWS`. */ |
| 7 | export default class CanaryFunction extends AWS.Lambda.Function<CanaryFunction>()( |
| 8 | "CanaryFunction", |
| 9 | { main: import.meta.url }, |
| 10 | Effect.gen(function* () { |
| 11 | const bucket = yield* AWS.S3.Bucket("CanaryBucket", {}); |
| 12 | const getObject = yield* AWS.S3.GetObject(bucket); |
| 13 | return { |
| 14 | fetch: Effect.gen(function* () { |
| 15 | const request = yield* HttpServerRequest; |
| 16 | const key = new URL(request.originalUrl).searchParams.get("key") ?? "index"; |
| 17 | const object = yield* getObject({ Key: key }); |
| 18 | return yield* HttpServerResponse.json({ contentLength: object.ContentLength }); |
| 19 | }).pipe(Effect.orDie), |
| 20 | }; |
| 21 | }).pipe(Effect.provide(AWS.S3.GetObjectHttp)), |
| 22 | ) {} |