| 1 | import * as AWS from "alchemy/AWS"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import * as Etag from "effect/http/Etag"; |
| 5 | import * as HttpPlatform from "effect/http/HttpPlatform"; |
| 6 | import * as HttpRouter from "effect/http/HttpRouter"; |
| 7 | import { JobApiLive } from "./JobApi.ts"; |
| 8 | import { JobNotificationsSNS } from "./JobNotifications.ts"; |
| 9 | import { JobStorageDynamoDB } from "./JobStorage.ts"; |
| 10 | |
| 11 | export default class JobFunction extends AWS.Lambda.Function<JobFunction>()( |
| 12 | "JobFunction", |
| 13 | { |
| 14 | main: import.meta.url, |
| 15 | functionUrl: true, |
| 16 | }, |
| 17 | HttpRouter.toHttpEffect(JobApiLive).pipe( |
| 18 | Effect.map((fetch) => ({ fetch })), |
| 19 | Effect.provide( |
| 20 | Layer.mergeAll( |
| 21 | JobStorageDynamoDB, |
| 22 | JobNotificationsSNS, |
| 23 | // TODO(sam): these should be provided to us automatically |
| 24 | HttpPlatform.layer, |
| 25 | Etag.layer, |
| 26 | ), |
| 27 | ), |
| 28 | ), |
| 29 | ) {} |