feat: Add database connection handling to server hooks
This commit is contained in:
@@ -3,11 +3,11 @@ import type { PageServerLoad } from './$types';
|
||||
import PG from '$lib/server/database';
|
||||
import { error } from '@sveltejs/kit';
|
||||
|
||||
export const load: PageServerLoad = async ({ params }) => {
|
||||
export const load: PageServerLoad = async ({ params, locals }) => {
|
||||
const { category, id } = params;
|
||||
console.log(id);
|
||||
|
||||
const db = await PG();
|
||||
const db = await PG(locals.db);
|
||||
await db.begin();
|
||||
try {
|
||||
const article = await db.query(
|
||||
|
||||
@@ -3,11 +3,11 @@ import type { PageServerLoad } from './$types';
|
||||
import PG from '$lib/server/database';
|
||||
import { error } from '@sveltejs/kit';
|
||||
|
||||
export const load: PageServerLoad = async ({ params }) => {
|
||||
export const load: PageServerLoad = async ({ params, locals }) => {
|
||||
const { category, id, series } = params;
|
||||
console.log(id);
|
||||
|
||||
const db = await PG();
|
||||
const db = await PG(locals.db);
|
||||
await db.begin();
|
||||
try {
|
||||
const article = await db.query(
|
||||
|
||||
Reference in New Issue
Block a user