supabase connection

This commit is contained in:
2026-02-21 23:18:57 +05:30
parent 40a33fc3b7
commit f6af2d2827
3 changed files with 26 additions and 7 deletions

View File

@@ -1,15 +1,21 @@
import { config } from 'dotenv';
config({ path: '.env.local' });
import { Pool } from 'pg';
import { config } from 'dotenv';
console.log('process.env:', process.env);
const connectionString = process.env.DATABASE_URL;
// Load environment variables based on the environment
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) {
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({

View File

@@ -20,6 +20,7 @@
"devDependencies": {
"@tailwindcss/postcss": "^4",
"@types/node": "^20",
"@types/pg": "^8.16.0",
"@types/react": "^19",
"@types/react-dom": "^19",
"biome": "^0.3.3",

12
pnpm-lock.yaml generated
View File

@@ -30,6 +30,9 @@ importers:
'@types/node':
specifier: ^20
version: 20.19.31
'@types/pg':
specifier: ^8.16.0
version: 8.16.0
'@types/react':
specifier: ^19
version: 19.2.11
@@ -375,6 +378,9 @@ packages:
'@types/node@20.19.31':
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':
resolution: {integrity: sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==}
peerDependencies:
@@ -1303,6 +1309,12 @@ snapshots:
dependencies:
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)':
dependencies:
'@types/react': 19.2.11