|
|
|
@ -1,19 +1,14 @@
|
|
|
|
import { db } from '$lib/db'
|
|
|
|
import { db } from '$lib/db'
|
|
|
|
import type { PageServerLoad } from './$types'
|
|
|
|
import type { PageServerLoad } from './$types'
|
|
|
|
import { redirect } from '@sveltejs/kit'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const load = (async (event) => {
|
|
|
|
export const load = (async (event) => {
|
|
|
|
if (!event.locals.user) {
|
|
|
|
const user = event.locals.userObject
|
|
|
|
throw redirect(303, '/')
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const userId = event.locals.user
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const shorteners = await db.query.shortener.findMany({
|
|
|
|
const shorteners = await db.query.shortener.findMany({
|
|
|
|
with: {
|
|
|
|
with: {
|
|
|
|
visitor: true,
|
|
|
|
visitor: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
where: (shortener, { eq }) => eq(shortener.userId, userId),
|
|
|
|
where: (shortener, { eq }) => eq(shortener.userId, user.id),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
return { shorteners }
|
|
|
|
return { shorteners }
|
|
|
|
|