Open History to see the last commit
1export default defineEventHandler(async (event) => {
2 const query = getQuery(event)
3 const cursor =
4 typeof query.cursor === 'string' ? parseInt(query.cursor) || 0 : 0
5 const pageSize = 5
6β
7 const data = Array(pageSize)
8 .fill(0)
9 .map((_, i) => {
10 return {
11 name: 'Project ' + (i + cursor) + ` (server time: ${Date.now()})`,
12 id: i + cursor,
13 }
14 })
15β
16 const nextId = cursor < 10 ? data[data.length - 1]!.id + 1 : null
17 const previousId = cursor > -10 ? data[0]!.id - pageSize : null
18β
19 await new Promise((r) => setTimeout(r, 1000))
20β
21 return { data, nextId, previousId }
22})