1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-20 21:01:18 -04:00

major upgrade to next 14 (#1834)

This commit is contained in:
2023-12-05 10:58:03 -05:00
committed by GitHub
parent e41807988a
commit fd21451de8
10 changed files with 697 additions and 671 deletions

View File

@@ -1,11 +1,20 @@
import { PrismaClient } from "@prisma/client";
import { PrismaNeon } from "@prisma/adapter-neon";
import { Pool, neonConfig } from "@neondatabase/serverless";
import ws from "ws";
// https://www.prisma.io/blog/serverless-database-drivers-KML1ehXORxZV#use-neon-with-neondatabaseserverless
neonConfig.webSocketConstructor = ws;
const connectionString = `${process.env.DATABASE_URL}`;
// creating PrismaClient here prevents next.js from starting too many concurrent prisma instances and exhausting the
// number of connection pools available (especially when hot reloading from `next dev`).
// https://www.prisma.io/docs/guides/other/troubleshooting-orm/help-articles/nextjs-prisma-client-dev-practices
const prismaClientSingleton = () => {
return new PrismaClient();
const pool = new Pool({ connectionString });
const adapter = new PrismaNeon(pool);
return new PrismaClient({ adapter });
};
type PrismaClientSingleton = ReturnType<typeof prismaClientSingleton>;