Skip to content

Commit

Permalink
chore: idk anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
rvcas committed Apr 6, 2024
1 parent ab97205 commit 6ffd09d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 101 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@
"type": "module",
"dependencies": {
"@dcspark/cardano-multiplatform-lib-nodejs": "^5.2.0",
"@prisma/adapter-pg-worker": "^5.12.1",
"@prisma/client": "^5.12.1",
"@prisma/pg-worker": "^5.12.1",
"d3-array": "^3.2.4",
"d3-scale": "^4.0.2",
"d3-shape": "^3.2.0",
Expand Down
93 changes: 0 additions & 93 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 21 additions & 6 deletions src/lib/server/dbsync.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
import { PrismaClient } from '@prisma/client';
import { PrismaPg } from '@prisma/adapter-pg-worker';
import { Pool } from '@prisma/pg-worker';

import { DATABASE_URL } from '$env/static/private';
import { NODE_ENV } from '$env/static/private';

const pool = new Pool({ connectionString: DATABASE_URL });
const adapter = new PrismaPg(pool);
let dbsync: PrismaClient;

export const dbsync = new PrismaClient({ adapter });
declare global {
// eslint-disable-next-line no-var
var __dbsync: PrismaClient | undefined;
}

// this is needed because in development we don't want to restart
// the server with every change, but we want to make sure we don't
// create a new connection to the DB with every change either.
if (NODE_ENV === 'production') {
dbsync = new PrismaClient();
} else {
if (!global.__dbsync) {
global.__dbsync = new PrismaClient({ log: ['query'] });
}

dbsync = global.__dbsync;
}

export { dbsync };

0 comments on commit 6ffd09d

Please sign in to comment.