Add basic loading of older posts

This commit is contained in:
2023-04-03 17:24:59 +02:00
parent 2eddb77b74
commit e8e864bdfc
4 changed files with 64 additions and 15 deletions

View File

@ -4,12 +4,13 @@ import { json } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
export const GET = (async ({ url }) => {
const since = url.searchParams.get('since');
let count = Number.parseInt(url.searchParams.get('count') || '');
if (isNaN(count)) {
count = 20;
}
count = Math.min(count, 100);
const posts = await getPosts(since, count);
return json(posts);
const since = url.searchParams.get('since');
const before = url.searchParams.get('before');
let count = Number.parseInt(url.searchParams.get('count') || '');
if (isNaN(count)) {
count = 20;
}
count = Math.min(count, 100);
const posts = await getPosts(since, before, count);
return json(posts);
}) satisfies RequestHandler;