From 0a257e915075fcc2afb580667185f3866c417d6c Mon Sep 17 00:00:00 2001 From: Siddharth Suresh Date: Fri, 14 Feb 2025 20:32:08 +0530 Subject: [PATCH] fix: Pages router template (#4423) * fixes * fix * Create tall-waves-marry.md --- .changeset/tall-waves-marry.md | 5 +++++ .../generator/src/generators/app-generator.ts | 16 +++++++++++++--- .../generator/templates/pages/package.js.json | 6 +++--- .../generator/templates/pages/package.ts.json | 6 +++--- 4 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 .changeset/tall-waves-marry.md diff --git a/.changeset/tall-waves-marry.md b/.changeset/tall-waves-marry.md new file mode 100644 index 0000000000..9ae72f8bf0 --- /dev/null +++ b/.changeset/tall-waves-marry.md @@ -0,0 +1,5 @@ +--- +"@blitzjs/generator": patch +--- + +fix: Pages router blitz rpc api not generated in the correct format diff --git a/packages/generator/src/generators/app-generator.ts b/packages/generator/src/generators/app-generator.ts index c72d4d3ea4..17caf637ca 100644 --- a/packages/generator/src/generators/app-generator.ts +++ b/packages/generator/src/generators/app-generator.ts @@ -68,18 +68,28 @@ export class AppGenerator extends Generator { this.destinationPath("package.json"), ) - const rpcEndpointPath = `src/app/api/rpc/blitzrpcroute/route.${ + const appRpcEndpointPath = `src/app/api/rpc/blitzrpcroute/route.${ this.options.useTs ? "ts" : "js" }` - if (this.fs.exists(rpcEndpointPath)) { + if (this.fs.exists(appRpcEndpointPath)) { this.fs.move( - this.destinationPath(rpcEndpointPath), + this.destinationPath(appRpcEndpointPath), this.destinationPath( `src/app/api/rpc/[[...blitz]]/route.${this.options.useTs ? "ts" : "js"}`, ), ) } + const pagesRpcEndpointPath = `src/pages/api/rpc/blitzrpcroute.${ + this.options.useTs ? "ts" : "js" + }` + if (this.fs.exists(pagesRpcEndpointPath)) { + this.fs.move( + this.destinationPath(pagesRpcEndpointPath), + this.destinationPath(`src/pages/api/rpc/[[...blitz]].${this.options.useTs ? "ts" : "js"}`), + ) + } + if (this.options.template.path === "app") { const pathsToMove = [ "src/app/auth/components/LoginForm.tsx", diff --git a/packages/generator/templates/pages/package.js.json b/packages/generator/templates/pages/package.js.json index 95a1101b45..5e5b8d6c09 100644 --- a/packages/generator/templates/pages/package.js.json +++ b/packages/generator/templates/pages/package.js.json @@ -27,10 +27,10 @@ "@blitzjs/rpc": "latest", "@prisma/client": "6.1.0", "blitz": "latest", - "next": "14.2.15", + "next": "15.0.1", "prisma": "6.1.0", - "react": "18.2.0", - "react-dom": "18.2.0", + "react": "19.0.0", + "react-dom": "19.0.0", "secure-password": "4.0.0", "zod": "3.23.8" }, diff --git a/packages/generator/templates/pages/package.ts.json b/packages/generator/templates/pages/package.ts.json index d02f37cf94..7695c8ef0b 100644 --- a/packages/generator/templates/pages/package.ts.json +++ b/packages/generator/templates/pages/package.ts.json @@ -27,10 +27,10 @@ "@blitzjs/rpc": "latest", "@prisma/client": "6.1.0", "blitz": "latest", - "next": "14.2.15", + "next": "15.0.1", "prisma": "6.1.0", - "react": "18.2.0", - "react-dom": "18.2.0", + "react": "19.0.0", + "react-dom": "19.0.0", "secure-password": "4.0.0", "zod": "3.23.8" },