14 lines
513 B
TypeScript
14 lines
513 B
TypeScript
import { json, error } from '@sveltejs/kit';
|
|
import { getNotifications } from '$lib/server/notifications';
|
|
import type { RequestHandler } from './$types';
|
|
|
|
export const GET: RequestHandler = async ({ locals, url }) => {
|
|
if (!locals.user) error(401, 'Not logged in');
|
|
|
|
const limit = parseInt(url.searchParams.get('limit') ?? '50');
|
|
const offset = parseInt(url.searchParams.get('offset') ?? '0');
|
|
|
|
const notifications = await getNotifications(locals.user.id, { limit, offset });
|
|
return json(notifications);
|
|
};
|