Skip to content

Commit

Permalink
Revert db init
Browse files Browse the repository at this point in the history
  • Loading branch information
sandervspl committed Jul 26, 2024
1 parent 29de1f8 commit ed4af22
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
1 change: 1 addition & 0 deletions apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hotkeys-hook": "^4.5.0",
"server-only": "^0.0.1",
"sonner": "^1.4.32",
"tailwind-merge": "^2.2.2",
"tailwind-variants": "^0.2.1",
Expand Down
29 changes: 15 additions & 14 deletions apps/website/src/db/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import 'server-only';
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';

import * as schema from './schema';

// const queryClient = postgres(process.env.DB_URL!);
// export const db = drizzle(queryClient, { schema });
const queryClient = postgres(process.env.DB_URL!);
export const db = drizzle(queryClient, { schema });

let db: ReturnType<typeof drizzle>;
// let db: ReturnType<typeof drizzle>;

if (process.env.NODE_ENV === 'production') {
const queryClient = postgres(process.env.DB_URL!);
db = drizzle(queryClient, { schema });
} else {
const queryClient = postgres(process.env.DB_URL!);
if (!global.db) {
global.db = drizzle(queryClient, { schema });
}
// if (process.env.NODE_ENV === 'production') {
// const queryClient = postgres(process.env.DB_URL!);
// db = drizzle(queryClient, { schema });
// } else {
// const queryClient = postgres(process.env.DB_URL!);
// if (!global.db) {
// global.db = drizzle(queryClient, { schema });
// }

db = global.db;
}
// db = global.db;
// }

export { db };
// export { db };
2 changes: 1 addition & 1 deletion apps/website/tsconfig.tsbuildinfo

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions pnpm-lock.yaml

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

0 comments on commit ed4af22

Please sign in to comment.