Skip to content

Commit

Permalink
fix: edge runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
RUNFUNRUN committed Aug 3, 2024
1 parent 2d90277 commit e02dac7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Binary file modified bun.lockb
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"postinstall": "prisma generate",
"postinstall": "prisma generate --no-engine",
"vercel-build": "prisma generate && next build && prisma migrate deploy",
"format": "biome format --write .",
"lint": "biome lint .",
Expand All @@ -21,6 +21,7 @@
"@next/third-parties": "^14.2.5",
"@prisma/adapter-neon": "^5.17.0",
"@prisma/client": "^5.17.0",
"@prisma/extension-accelerate": "^1.1.0",
"@radix-ui/react-avatar": "^1.1.0",
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-dropdown-menu": "^2.1.1",
Expand Down
5 changes: 4 additions & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { PrismaClient } from '@prisma/client';
import { withAccelerate } from '@prisma/extension-accelerate';
import { PrismaNeon } from '@prisma/adapter-neon';
import { Pool } from '@neondatabase/serverless';

const globalForPrisma = globalThis as unknown as { prisma: PrismaClient };

const neon = new Pool({ connectionString: process.env.POSTGRES_PRISMA_URL });
const adapter = new PrismaNeon(neon);
export const prisma = globalForPrisma.prisma || new PrismaClient({ adapter });
export const prisma =
globalForPrisma.prisma ||
new PrismaClient({ adapter }).$extends(withAccelerate());

if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;

0 comments on commit e02dac7

Please sign in to comment.