feat: Add database connection handling to server hooks

This commit is contained in:
2024-08-28 00:13:46 +09:00
parent e7949b6c5f
commit d3cc3145e0
8 changed files with 109 additions and 87 deletions
+15
View File
@@ -0,0 +1,15 @@
import pg from 'pg';
const { Pool } = pg;
import {
PG_USER,
PG_PASS,
PG_HOST,
PG_PORT,
PG_DB,
} from '$env/static/private'
const connectionString = `postgres://${PG_USER}:${PG_PASS}@${PG_HOST}:${PG_PORT}/${PG_DB}`;
const pool = new Pool({ connectionString });
export const getConnection = () => pool;