Skip to content

Compute

Source: src/Prisma/Compute.ts

A Prisma Compute deployment resource.

Prisma’s create-deployment API exposes neither an idempotency key nor a caller-defined recovery key. If the API commits a deployment but its create response is lost before Alchemy persists the returned ID, that deployment can remain orphaned and a later deploy may create another one. Alchemy does not guess that the App’s latest deployment is owned, because it could belong to another actor. Use a durable, locked state backend and inspect the App’s deployment history after an interrupted create.

Deploy a directory with an entrypoint

const app = yield* Prisma.Compute("api", {
project: project.projectId,
path: "./apps/api",
entrypoint: "server.ts",
port: 3000,
});

Deploy an Effect-native HTTP app

export default Prisma.Compute(
"api",
{
project,
appName: "api",
main: import.meta.filename,
port: 8080,
},
Effect.gen(function* () {
return {
fetch: HttpServerResponse.text("ok"),
};
}),
);

Bind a Prisma Connection

export default Prisma.Compute(
"api",
{
project,
appName: "api",
main: import.meta.filename,
},
Effect.gen(function* () {
const db = yield* Prisma.Connect(connection);
const sql = yield* SQL.Postgres({ url: db.databaseUrl });
return {
fetch: Effect.gen(function* () {
const users = yield* sql`SELECT * FROM users`;
return HttpServerResponse.json(users);
}),
};
}).pipe(Effect.provide(Prisma.ConnectBinding)),
);

Build before upload and replace old versions

const app = yield* Prisma.Compute("api", {
project: project.projectId,
path: "./apps/api",
build: {
command: "bun build src/server.ts --target bun --outdir dist",
outdir: "dist",
entrypoint: "server.js",
},
port: 8080,
env: {
DATABASE_URL: database.directConnectionString,
},
destroyOldDeployment: true,
});

Auto-build a framework app

const app = yield* Prisma.Compute("api", {
project: project.projectId,
path: "./apps/web",
build: "auto",
destroyOldDeployment: true,
});

Deploy a prebuilt tar.gz artifact

const app = yield* Prisma.Compute("api", {
project: project.projectId,
artifactPath: "./dist/app.tar.gz",
port: 8080,
});
const app = yield* Prisma.Compute("api", {
project,
path: "./apps/api",
entrypoint: "server.ts",
healthCheck: {
path: "/api/health",
// Defaults to any 2xx response when omitted.
statusCodes: [200, 204],
},
});
const app = yield* Prisma.Compute("api", {
project: project.projectId,
path: "./apps/api",
entrypoint: "server.ts",
dev: {
command: "bun run dev",
port: 3000,
},
});