mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
Add new tests to server routes
This commit is contained in:
parent
6263c667e8
commit
6b3c604c33
7 changed files with 524 additions and 17 deletions
|
|
@ -39,13 +39,13 @@ export async function fetchTimeline<T extends User | Status | Notification>(
|
|||
const urlWithoutQuery = req.url.split("?")[0];
|
||||
// Add prev link
|
||||
linkHeader.push(
|
||||
`<${urlWithoutQuery}?min_id=${objects[0].id}>; rel="prev"`,
|
||||
`<${urlWithoutQuery}?limit=${args?.limit ?? 20}&min_id=${
|
||||
objects[0].id
|
||||
}>; rel="prev"`,
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
objects.length < (Number(args?.limit) ?? Number.POSITIVE_INFINITY)
|
||||
) {
|
||||
if (objects.length >= (Number(args?.limit) ?? 20)) {
|
||||
// Check if there are statuses after the last one
|
||||
// @ts-expect-error hack again
|
||||
const objectsAfter = await model({
|
||||
|
|
@ -59,7 +59,9 @@ export async function fetchTimeline<T extends User | Status | Notification>(
|
|||
const urlWithoutQuery = req.url.split("?")[0];
|
||||
// Add next link
|
||||
linkHeader.push(
|
||||
`<${urlWithoutQuery}?max_id=${objectsAfter[0].id}>; rel="next"`,
|
||||
`<${urlWithoutQuery}?limit=${args?.limit ?? 20}&max_id=${
|
||||
objects.at(-1)?.id
|
||||
}>; rel="next"`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue