mirror of
https://github.com/VibedByKaKi/t3-code-android-nightly.git
synced 2026-10-14 14:27:45 +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 `/api/*` path rule. */
|
|
export class ApiTargetFunction extends Lambda.Function<Lambda.Function>()(
|
|
"ApiTargetFunction",
|
|
) {}
|
|
|
|
export const ApiTargetFunctionLive = ApiTargetFunction.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: "api",
|
|
path: pathname,
|
|
});
|
|
}).pipe(Effect.orDie),
|
|
};
|
|
}),
|
|
);
|
|
|
|
export default ApiTargetFunctionLive;
|