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}`;

let pool = new Pool({ connectionString });

export const getPool = pool;

export const reConnect = async () => {
  pool = new Pool({ connectionString });
}

import { init as init_data} from '$lib/server/data_loader';
import PG from '$lib/server/database/postgres';
import git from '$lib/server/git';
await init_data(await PG(pool), git);