The best way to control Claude Code, Codex and more from any computer or phone

main
ts 55 lines 1.92 KB
Raw
1 // Deep imports keep the Compute bundle lean (see ./bucket.ts).
2 import { Compute } from "@alchemy.run/prisma/Compute";
3 import { Project } from "@alchemy.run/prisma/Project";
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 "@alchemy.run/prisma",
17 ]);
18
19 export const IsolatedProjectPrismaProject = Project("PrismaIsolatedProjectProject", {
20 name: "alchemy-isolated-project",
21 createDatabase: false,
22 });
23
24 /**
25 * Minimal Effect-native `Prisma.Compute` app served from an isolated
26 * project. `/health` answering 200 proves the generated bootstrap booted —
27 * with its imports left external bun dies at module load and the deployment
28 * never becomes reachable.
29 */
30 export default Compute(
31 "PrismaIsolatedProjectCompute",
32 Effect.gen(function* () {
33 const prismaProject = yield* IsolatedProjectPrismaProject;
34 return {
35 project: prismaProject,
36 appName: "alchemy-isolated-project",
37 main: project.main,
38 port: 8080,
39 timeoutSeconds: 240,
40 destroyOldDeployment: true,
41 };
42 }),
43 Effect.gen(function* () {
44 return {
45 fetch: Effect.gen(function* () {
46 const request = yield* HttpServerRequest;
47 const url = new URL(request.url, "http://app");
48 if (url.pathname === "/health") {
49 return yield* HttpServerResponse.json({ ok: true });
50 }
51 return HttpServerResponse.text("hello from isolated project");
52 }),
53 };
54 }),
55 );