feat: Add database connection handling to server hooks
This commit is contained in:
@@ -18,8 +18,8 @@ let data: {
|
||||
updated: "",
|
||||
};
|
||||
|
||||
export const load: PageServerLoad = async ({ params }) => {
|
||||
const db = await PG();
|
||||
export const load: PageServerLoad = async ({ params, locals }) => {
|
||||
const db = await PG(locals.db);
|
||||
await db.begin();
|
||||
try {
|
||||
const recent_articles = 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 } = 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