convert analytics to TS

This commit is contained in:
chreamy authored and wancat committed 2024-02-28 23:38:33 +08:00
1 parent fb69cb4e10
commit 923de901c4
24 files changed
+11093 -211

No files matched your search

@@ -0,0 +1,22 @@
import Pagination from '../models/pagination.ts'
import { userList } from '../models/users.js'
export async function userListController(req: any, res: any) {
const { nextKey, order } = req.query
const itemsPerPage = 50
try {
const pagination = new Pagination(order, itemsPerPage, nextKey)
const users = await userList(pagination)
const newNextKey = users[users.length - 1]?._id
res.render('users', {
users,
nextKey: newNextKey,
order: pagination.getOrder(),
})
} catch (error) {
console.error(error)
res.status(500).send('Error fetching user data')
}
}