Open History to see the last commit
1import type { NextApiRequest, NextApiResponse } from 'next'
2β
3export default (req: NextApiRequest, res: NextApiResponse) => {
4 const cursor =
5 typeof req.query.cursor === 'string' ? parseInt(req.query.cursor) || 0 : 0
6 const pageSize = 4
7β
8 const data = Array(pageSize)
9 .fill(0)
10 .map((_, i) => {
11 return {
12 name: 'Project ' + (i + cursor) + ` (server time: ${Date.now()})`,
13 id: i + cursor,
14 }
15 })
16β
17 const nextId = cursor < 20 ? data[data.length - 1].id + 1 : null
18 const previousId = cursor > -20 ? data[0].id - pageSize : null
19β
20 setTimeout(() => res.json({ data, nextId, previousId }), 300)
21}