feat: Changed to not use getConnection function directly from the page.
This commit is contained in:
parent
632521e7f4
commit
0398b95c24
|
@ -7,17 +7,16 @@ 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 }) => {
|
export const POST: RequestHandler = async ({ url, locals }) => {
|
||||||
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(getConnection()));
|
await init(await PG(locals.db));
|
||||||
return new Response(String(token));
|
return new Response(String(token));
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user