Compare commits
No commits in common. "4c87679fbe087352486025e7fc339d79e69f59c7" and "632521e7f4dd6185385406d0e4d9cabe28c08fab" have entirely different histories.
4c87679fbe
...
632521e7f4
|
@ -1,4 +1,5 @@
|
||||||
import pg from 'pg';
|
import pg from 'pg';
|
||||||
|
import { getConnection } from './database/get_connection';
|
||||||
|
|
||||||
export class Postgres {
|
export class Postgres {
|
||||||
client: pg.PoolClient | null = null;
|
client: pg.PoolClient | null = null;
|
||||||
|
@ -32,3 +33,7 @@ export class Postgres {
|
||||||
export default async (
|
export default async (
|
||||||
pool: pg.Pool
|
pool: pg.Pool
|
||||||
) => { return await Postgres.new(pool); };
|
) => { return await Postgres.new(pool); };
|
||||||
|
|
||||||
|
import { building } from '$app/environment';
|
||||||
|
import init from '$lib/server/database/init_db';
|
||||||
|
if (!building) await init(await Postgres.new(getConnection()));
|
||||||
|
|
|
@ -13,7 +13,3 @@ const connectionString = `postgres://${PG_USER}:${PG_PASS}@${PG_HOST}:${PG_PORT}
|
||||||
const pool = new Pool({ connectionString });
|
const pool = new Pool({ connectionString });
|
||||||
|
|
||||||
export const getConnection = () => pool;
|
export const getConnection = () => pool;
|
||||||
|
|
||||||
import init from '$lib/server/database/init_db';
|
|
||||||
import PG from '$lib/server/database';
|
|
||||||
await init(await PG(pool));
|
|
|
@ -7,16 +7,17 @@ import {
|
||||||
} from '$env/static/private'
|
} from '$env/static/private'
|
||||||
|
|
||||||
import PG from '$lib/server/database';
|
import PG from '$lib/server/database';
|
||||||
|
import { getConnection } from '$lib/server/database/get_connection';
|
||||||
// import { building } from '$app/environment';
|
// import { building } from '$app/environment';
|
||||||
import init from '$lib/server/database/init_db';
|
import init from '$lib/server/database/init_db';
|
||||||
|
|
||||||
export const POST: RequestHandler = async ({ url, locals }) => {
|
export const POST: RequestHandler = async ({ url }) => {
|
||||||
const token = url.searchParams.get('token');
|
const token = url.searchParams.get('token');
|
||||||
console.log(token);
|
console.log(token);
|
||||||
if (token !== TOKEN) {
|
if (token !== TOKEN) {
|
||||||
return error(401, 'Unauthorized');
|
return error(401, 'Unauthorized');
|
||||||
}
|
}
|
||||||
|
|
||||||
await init(await PG(locals.db));
|
await init(await PG(getConnection()));
|
||||||
return new Response(String(token));
|
return new Response(String(token));
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user