mirror of
https://github.com/VibedByKaKi/t3-code-android-nightly.git
synced 2026-10-11 21:01:16 +02:00
33 lines
962 B
TypeScript
33 lines
962 B
TypeScript
import * as Lambda from "@/AWS/Lambda";
|
|
import * as Duration from "effect/Duration";
|
|
import * as Effect from "effect/Effect";
|
|
import { HttpServerRequest } from "effect/http/HttpServerRequest";
|
|
import * as HttpServerResponse from "effect/http/HttpServerResponse";
|
|
|
|
const main = import.meta.url;
|
|
|
|
/** ALB Lambda target answering the `/web/*` path rule. */
|
|
export class WebTargetFunction extends Lambda.Function<Lambda.Function>()(
|
|
"WebTargetFunction",
|
|
) {}
|
|
|
|
export const WebTargetFunctionLive = WebTargetFunction.make(
|
|
{
|
|
main,
|
|
timeout: Duration.seconds(30),
|
|
},
|
|
Effect.gen(function* () {
|
|
return {
|
|
fetch: Effect.gen(function* () {
|
|
const request = yield* HttpServerRequest;
|
|
const pathname = new URL(request.originalUrl).pathname;
|
|
return yield* HttpServerResponse.json({
|
|
target: "web",
|
|
path: pathname,
|
|
});
|
|
}).pipe(Effect.orDie),
|
|
};
|
|
}),
|
|
);
|
|
|
|
export default WebTargetFunctionLive;
|