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

main
ts 23 lines 1.01 KB
Raw
1 import * as Lambda from "@alchemy.run/aws/Lambda";
2 import * as S3 from "@alchemy.run/aws/S3";
3 import * as Effect from "effect/Effect";
4 import { HttpServerRequest } from "effect/http/HttpServerRequest";
5 import * as HttpServerResponse from "effect/http/HttpServerResponse";
6
7 /** The same Lambda as `aws-namespace.ts`, importing each service by path. */
8 export default class CanaryFunction extends Lambda.Function<CanaryFunction>()(
9 "CanaryFunction",
10 { main: import.meta.url },
11 Effect.gen(function* () {
12 const bucket = yield* S3.Bucket("CanaryBucket", {});
13 const getObject = yield* S3.GetObject(bucket);
14 return {
15 fetch: Effect.gen(function* () {
16 const request = yield* HttpServerRequest;
17 const key = new URL(request.originalUrl).searchParams.get("key") ?? "index";
18 const object = yield* getObject({ Key: key });
19 return yield* HttpServerResponse.json({ contentLength: object.ContentLength });
20 }).pipe(Effect.orDie),
21 };
22 }).pipe(Effect.provide(S3.GetObjectHttp)),
23 ) {}