| 1 | // Deep imports keep the Compute bundle lean (see ./bucket.ts). |
| 2 | import { Compute } from "@/Prisma/Compute.ts"; |
| 3 | import { Project } from "@/Prisma/Project.ts"; |
| 4 | import * as Effect from "effect/Effect"; |
| 5 | import { HttpServerRequest } from "effect/http/HttpServerRequest"; |
| 6 | import * as HttpServerResponse from "effect/http/HttpServerResponse"; |
| 7 | import { isolatedProject } from "../../IsolatedProject.ts"; |
| 8 | |
| 9 | /** |
| 10 | * The isolated consumer project this app is bundled from (see |
| 11 | * `test/IsolatedProject.ts`): `main` lives outside the repository, so the |
| 12 | * bundle `cwd` resolves none of alchemy's dependencies and the bun |
| 13 | * bootstrap's own imports must be anchored by the bundler. |
| 14 | */ |
| 15 | export const project = isolatedProject("prisma-compute", import.meta.filename); |
| 16 | |
| 17 | export const IsolatedProjectPrismaProject = Project( |
| 18 | "PrismaIsolatedProjectProject", |
| 19 | { |
| 20 | name: "alchemy-isolated-project", |
| 21 | createDatabase: false, |
| 22 | }, |
| 23 | ); |
| 24 | |
| 25 | /** |
| 26 | * Minimal Effect-native `Prisma.Compute` app served from an isolated |
| 27 | * project. `/health` answering 200 proves the generated bootstrap booted — |
| 28 | * with its imports left external bun dies at module load and the deployment |
| 29 | * never becomes reachable. |
| 30 | */ |
| 31 | export default Compute( |
| 32 | "PrismaIsolatedProjectCompute", |
| 33 | Effect.gen(function* () { |
| 34 | const prismaProject = yield* IsolatedProjectPrismaProject; |
| 35 | return { |
| 36 | project: prismaProject, |
| 37 | appName: "alchemy-isolated-project", |
| 38 | main: project.main, |
| 39 | port: 8080, |
| 40 | timeoutSeconds: 240, |
| 41 | destroyOldDeployment: true, |
| 42 | }; |
| 43 | }), |
| 44 | Effect.gen(function* () { |
| 45 | return { |
| 46 | fetch: Effect.gen(function* () { |
| 47 | const request = yield* HttpServerRequest; |
| 48 | const url = new URL(request.url, "http://app"); |
| 49 | if (url.pathname === "/health") { |
| 50 | return yield* HttpServerResponse.json({ ok: true }); |
| 51 | } |
| 52 | return HttpServerResponse.text("hello from isolated project"); |
| 53 | }), |
| 54 | }; |
| 55 | }), |
| 56 | ); |