Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f6af2d2827 | |||
| 40a33fc3b7 | |||
| 8b3a53342e |
25
lib/db.ts
Normal file
25
lib/db.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Pool } from 'pg';
|
||||
import { config } from 'dotenv';
|
||||
|
||||
// Load environment variables based on the environment
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
config({ path: '.env.production' });
|
||||
} else {
|
||||
config({ path: '.env.local' });
|
||||
}
|
||||
|
||||
const connectionString = process.env.NODE_ENV === 'production'
|
||||
? process.env.SUPABASE_URL
|
||||
: process.env.DATABASE_URL;
|
||||
|
||||
console.log('Using connection string:', connectionString);
|
||||
|
||||
if (!connectionString) {
|
||||
throw new Error('Database connection URL is not set in environment variables');
|
||||
}
|
||||
|
||||
const pool = new Pool({
|
||||
connectionString,
|
||||
});
|
||||
|
||||
export default pool;
|
||||
@@ -11,17 +11,21 @@
|
||||
"check": "biome check ."
|
||||
},
|
||||
"dependencies": {
|
||||
"dotenv": "^17.3.1",
|
||||
"next": "16.1.6",
|
||||
"pg": "^8.18.0",
|
||||
"react": "19.2.3",
|
||||
"react-dom": "19.2.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4",
|
||||
"@types/node": "^20",
|
||||
"@types/pg": "^8.16.0",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"biome": "^0.3.3",
|
||||
"tailwindcss": "^4",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5"
|
||||
}
|
||||
}
|
||||
|
||||
3154
pnpm-lock.yaml
generated
3154
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "react-jsx",
|
||||
@@ -20,7 +20,8 @@
|
||||
],
|
||||
"paths": {
|
||||
"@/*": ["./*"]
|
||||
}
|
||||
},
|
||||
"allowImportingTsExtensions": true
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
|
||||
Reference in New Issue
Block a user