Add public timeline, fix limit param

This commit is contained in:
Alex Gleason
2023-07-07 15:07:20 -05:00
parent cacf51ea36
commit d4eef9c2af
4 changed files with 37 additions and 23 deletions

View File

@@ -78,9 +78,12 @@ async function parseBody(req: Request): Promise<unknown> {
const paginationSchema = z.object({
since: z.coerce.number().optional().catch(undefined),
until: z.coerce.number().optional().catch(undefined),
until: z.coerce.number().catch(nostrNow()),
limit: z.coerce.number().min(0).max(40).catch(20),
});
type PaginationParams = z.infer<typeof paginationSchema>;
function buildLinkHeader(url: string, events: Event[]): string | undefined {
if (!events.length) return;
const firstEvent = events[0];
@@ -103,6 +106,7 @@ export {
lookupAccount,
type Nip05,
nostrNow,
type PaginationParams,
paginationSchema,
parseBody,
parseNip05,