supabase connection
This commit is contained in:
20
lib/db.ts
20
lib/db.ts
@@ -1,15 +1,21 @@
|
|||||||
import { config } from 'dotenv';
|
|
||||||
config({ path: '.env.local' });
|
|
||||||
|
|
||||||
import { Pool } from 'pg';
|
import { Pool } from 'pg';
|
||||||
|
import { config } from 'dotenv';
|
||||||
|
|
||||||
console.log('process.env:', process.env);
|
// Load environment variables based on the environment
|
||||||
const connectionString = process.env.DATABASE_URL;
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
config({ path: '.env.production' });
|
||||||
|
} else {
|
||||||
|
config({ path: '.env.local' });
|
||||||
|
}
|
||||||
|
|
||||||
console.log('DATABASE_URL in lib/db.ts:', connectionString);
|
const connectionString = process.env.NODE_ENV === 'production'
|
||||||
|
? process.env.SUPABASE_URL
|
||||||
|
: process.env.DATABASE_URL;
|
||||||
|
|
||||||
|
console.log('Using connection string:', connectionString);
|
||||||
|
|
||||||
if (!connectionString) {
|
if (!connectionString) {
|
||||||
throw new Error('DATABASE_URL is not set in environment variables');
|
throw new Error('Database connection URL is not set in environment variables');
|
||||||
}
|
}
|
||||||
|
|
||||||
const pool = new Pool({
|
const pool = new Pool({
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/postcss": "^4",
|
"@tailwindcss/postcss": "^4",
|
||||||
"@types/node": "^20",
|
"@types/node": "^20",
|
||||||
|
"@types/pg": "^8.16.0",
|
||||||
"@types/react": "^19",
|
"@types/react": "^19",
|
||||||
"@types/react-dom": "^19",
|
"@types/react-dom": "^19",
|
||||||
"biome": "^0.3.3",
|
"biome": "^0.3.3",
|
||||||
|
|||||||
12
pnpm-lock.yaml
generated
12
pnpm-lock.yaml
generated
@@ -30,6 +30,9 @@ importers:
|
|||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^20
|
specifier: ^20
|
||||||
version: 20.19.31
|
version: 20.19.31
|
||||||
|
'@types/pg':
|
||||||
|
specifier: ^8.16.0
|
||||||
|
version: 8.16.0
|
||||||
'@types/react':
|
'@types/react':
|
||||||
specifier: ^19
|
specifier: ^19
|
||||||
version: 19.2.11
|
version: 19.2.11
|
||||||
@@ -375,6 +378,9 @@ packages:
|
|||||||
'@types/node@20.19.31':
|
'@types/node@20.19.31':
|
||||||
resolution: {integrity: sha512-5jsi0wpncvTD33Sh1UCgacK37FFwDn+EG7wCmEvs62fCvBL+n8/76cAYDok21NF6+jaVWIqKwCZyX7Vbu8eB3A==}
|
resolution: {integrity: sha512-5jsi0wpncvTD33Sh1UCgacK37FFwDn+EG7wCmEvs62fCvBL+n8/76cAYDok21NF6+jaVWIqKwCZyX7Vbu8eB3A==}
|
||||||
|
|
||||||
|
'@types/pg@8.16.0':
|
||||||
|
resolution: {integrity: sha512-RmhMd/wD+CF8Dfo+cVIy3RR5cl8CyfXQ0tGgW6XBL8L4LM/UTEbNXYRbLwU6w+CgrKBNbrQWt4FUtTfaU5jSYQ==}
|
||||||
|
|
||||||
'@types/react-dom@19.2.3':
|
'@types/react-dom@19.2.3':
|
||||||
resolution: {integrity: sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==}
|
resolution: {integrity: sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -1303,6 +1309,12 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
undici-types: 6.21.0
|
undici-types: 6.21.0
|
||||||
|
|
||||||
|
'@types/pg@8.16.0':
|
||||||
|
dependencies:
|
||||||
|
'@types/node': 20.19.31
|
||||||
|
pg-protocol: 1.11.0
|
||||||
|
pg-types: 2.2.0
|
||||||
|
|
||||||
'@types/react-dom@19.2.3(@types/react@19.2.11)':
|
'@types/react-dom@19.2.3(@types/react@19.2.11)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/react': 19.2.11
|
'@types/react': 19.2.11
|
||||||
|
|||||||
Reference in New Issue
Block a user