Skip to content

Commit f01c247

Browse files
feat: enable Prisma Compute deploys for the NestJS template (#46)
* feat: enable Prisma Compute deploys for the NestJS template Compute's SDK gained a NestJS build strategy (project-compute #94), so the nest template can now deploy. Add it to COMPUTE_DEPLOYABLE_TEMPLATES and ship a prisma.compute.ts with framework "nestjs" (detected, no entrypoint; the default HTTP port 3000 matches the template's listen port). The compute:deploy script and README Compute sections wire up automatically off the deployable gate. * fix: actually deploy the NestJS template, add its compute-sdk dep Enabling nest needs three registries, not one. The first PR only added it to COMPUTE_DEPLOYABLE_TEMPLATES (which gates the deploy prompt), so the prompt showed but the deploy was skipped: - DEPLOY_OPTIONS_BY_TEMPLATE gates the actual deploy. Without a nest entry, collectComputeDeployContext returned null after the user confirmed, so no deploy ran and no URL was printed. - computeConfigTemplates adds @prisma/compute-sdk as a devDependency for the generated prisma.compute.ts types. nest is a single-app template, so its deploy entry is {} (no configTarget). * docs: list nest as a Compute-deployable template in the README * fix: nest build must emit compiled output for deploy (bun/node) The NestJS deploy strategy compiles and ships dist/, so its build script must emit. The shared runtimeScript helper used `tsc --noEmit` for bun (and `deno check` for deno) because those runtimes execute TypeScript directly — fine for hono/elysia (the SDK bundles their source) but it left nest with no dist/main.js, so deploys failed with "Build failed locally" under bun. Add an `emit` option to runtimeScript; nest opts in so its build compiles to dist on every node-style PM and bun. Deno keeps `deno check` — the Deno nest variant uses Deno APIs and isn't built for the node-based Compute runtime.
1 parent 3cc1dab commit f01c247

8 files changed

Lines changed: 25 additions & 4 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ Prisma Compute deployment is currently supported for:
101101

102102
- `hono`
103103
- `elysia`
104+
- `nest`
104105
- `next`
105106
- `astro`
106107
- `nuxt`
@@ -152,7 +153,7 @@ When Prisma Compute deploy is selected, the skills add-on recommends the `prisma
152153

153154
## Deploy to Prisma Compute
154155

155-
After scaffolding, `create-prisma` can deploy your app to [Prisma Compute](https://www.prisma.io/docs/compute), the serverless hosting for TypeScript apps that runs next to your Prisma Postgres database. It is offered for the templates the Prisma CLI can deploy today: `hono`, `elysia`, `next`, `astro`, `nuxt`, `tanstack-start`, and `turborepo`.
156+
After scaffolding, `create-prisma` can deploy your app to [Prisma Compute](https://www.prisma.io/docs/compute), the serverless hosting for TypeScript apps that runs next to your Prisma Postgres database. It is offered for the templates the Prisma CLI can deploy today: `hono`, `elysia`, `nest`, `next`, `astro`, `nuxt`, `tanstack-start`, and `turborepo`.
156157

157158
Accept the deploy prompt when it appears, or pass the flag:
158159

src/constants/dependencies.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export type CreateTemplateDependencyTarget = {
2828
const computeConfigTemplates = new Set<CreateTemplate>([
2929
"hono",
3030
"elysia",
31+
"nest",
3132
"next",
3233
"astro",
3334
"nuxt",

src/tasks/deploy-to-compute.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const DEPLOY_OPTIONS_BY_TEMPLATE: Partial<
2121
> = {
2222
hono: {},
2323
elysia: {},
24+
nest: {},
2425
next: {},
2526
astro: {},
2627
nuxt: {},

src/templates/shared.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ Handlebars.registerHelper(
102102
sourceEntrypoint,
103103
builtEntrypoint,
104104
denoFlags: getOptionalHashStringList(hash, "denoFlags"),
105+
emit: hash.emit === true,
105106
});
106107
},
107108
);

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export const CreateScaffoldOptionsSchema = z.object({
101101
export const COMPUTE_DEPLOYABLE_TEMPLATES: ReadonlySet<CreateTemplate> = new Set<CreateTemplate>([
102102
"hono",
103103
"elysia",
104+
"nest",
104105
"next",
105106
"astro",
106107
"nuxt",

src/utils/package-manager.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ type RuntimeScriptOptions = {
1414
sourceEntrypoint: string;
1515
builtEntrypoint?: string;
1616
denoFlags?: string[];
17+
// When true, `build` compiles to `dist` instead of only type-checking.
18+
// Templates that deploy a compiled artifact (e.g. NestJS) need this; bun and
19+
// deno otherwise run TypeScript directly and skip emit.
20+
emit?: boolean;
1721
};
1822

1923
const packageManagerManifestValues = {
@@ -198,7 +202,7 @@ export function getRuntimeScriptCommand(
198202
kind: RuntimeScriptKind,
199203
options: RuntimeScriptOptions,
200204
): string {
201-
const { sourceEntrypoint, builtEntrypoint, denoFlags = [] } = options;
205+
const { sourceEntrypoint, builtEntrypoint, denoFlags = [], emit = false } = options;
202206

203207
if (packageManager === "deno") {
204208
switch (kind) {
@@ -213,6 +217,9 @@ export function getRuntimeScriptCommand(
213217
sourceEntrypoint,
214218
]);
215219
case "build":
220+
// Deno runs TypeScript directly; there is no node-style compiled
221+
// artifact to emit here (the Deno nest variant uses Deno APIs and is
222+
// not built for the node-based Compute runtime).
216223
return `deno check ${sourceEntrypoint}`;
217224
case "start":
218225
return joinCommandParts([
@@ -231,7 +238,7 @@ export function getRuntimeScriptCommand(
231238
case "dev":
232239
return `bun --watch ${sourceEntrypoint}`;
233240
case "build":
234-
return "tsc --noEmit";
241+
return emit ? "tsc" : "tsc --noEmit";
235242
case "start":
236243
return `bun ${sourceEntrypoint}`;
237244
}

templates/create/nest/package.json.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"type": "module",
88
"scripts": {
99
"dev": "{{runtimeScript packageManager "dev" "src/main.ts" "dist/main.js"}}",
10-
"build": "{{runtimeScript packageManager "build" "src/main.ts" "dist/main.js"}}",
10+
"build": "{{runtimeScript packageManager "build" "src/main.ts" "dist/main.js" emit=true}}",
1111
"start": "{{runtimeScript packageManager "start" "src/main.ts" "dist/main.js"}}"
1212
},
1313
"dependencies": {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { defineComputeConfig } from "@prisma/compute-sdk/config";
2+
3+
export default defineComputeConfig({
4+
app: {
5+
name: "{{projectName}}",
6+
framework: "nestjs",
7+
env: ".env",
8+
},
9+
});

0 commit comments

Comments
 (0)