| 1 | import * as AWS from "alchemy/AWS"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import { MicrovmBuildRole } from "./build-role.ts"; |
| 4 | import { effectfulImpl } from "./effectful-impl.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Effectful MicroVM image on **node** — identical server to the bun effectful |
| 8 | * {@link import("./effectful-bun.ts").EffectfulBun}, but bundled for the node |
| 9 | * runtime (`dnf install -y nodejs`, no bun install). Since the Lambda MicroVM |
| 10 | * base ships node, this avoids the bun installer step entirely; comparing it to |
| 11 | * the bun effectful isolates the runtime's contribution to cold start. |
| 12 | */ |
| 13 | export class EffectfulNode extends AWS.Lambda.MicrovmImage< |
| 14 | EffectfulNode, |
| 15 | { |
| 16 | hello: (message: string) => Effect.Effect<string>; |
| 17 | } |
| 18 | >()("MicrovmEffectfulNode") {} |
| 19 | |
| 20 | export default EffectfulNode.make( |
| 21 | MicrovmBuildRole.pipe( |
| 22 | Effect.map((buildRole) => ({ |
| 23 | main: import.meta.filename, |
| 24 | buildRole, |
| 25 | runtime: "node" as const, |
| 26 | resources: [{ minimumMemoryInMiB: 512 }], |
| 27 | cpuConfigurations: [{ architecture: "ARM_64" }], |
| 28 | })), |
| 29 | ), |
| 30 | effectfulImpl, |
| 31 | ); |