Skip to content

Commit e4d9882

Browse files
done database setup using Postgres and railway
1 parent 994d151 commit e4d9882

File tree

22 files changed

+1573
-501
lines changed

22 files changed

+1573
-501
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ yarn-error.log*
2727

2828
# local env files
2929
.env*.local
30+
.env
3031

3132
# vercel
3233
.vercel

lib/db.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { PrismaClient } from "@prisma/client";
2+
3+
declare global {
4+
// eslint-disable-next-line no-var
5+
var cachedPrisma: PrismaClient;
6+
}
7+
8+
let prisma: PrismaClient;
9+
if (process.env.NODE_ENV === "production") {
10+
prisma = new PrismaClient();
11+
} else {
12+
if (!global.cachedPrisma) {
13+
global.cachedPrisma = new PrismaClient();
14+
}
15+
prisma = global.cachedPrisma;
16+
}
17+
18+
export const db = prisma;

0 commit comments

Comments
 (0)