1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-19 13:55:31 -04:00

goodbye planetscale 🪦 hello turso 👋

This commit is contained in:
2024-04-01 11:12:24 -04:00
parent 1813de3f0a
commit 971747a161
12 changed files with 256 additions and 18 deletions

View File

@@ -1,11 +1,21 @@
import { PrismaClient } from "@prisma/client";
import { PrismaLibSQL } from "@prisma/adapter-libsql";
import { createClient } from "@libsql/client";
// 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 libsql = createClient({
// TODO: use a local .db file for development. https://www.prisma.io/docs/orm/overview/databases/sqlite#connection-url
url: `${process.env.TURSO_DATABASE_URL}`,
authToken: `${process.env.TURSO_AUTH_TOKEN}`,
});
const adapter = new PrismaLibSQL(libsql);
return new PrismaClient({ adapter });
};
declare global {