mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 11:30:13 +08:00
23 lines
602 B
JavaScript
23 lines
602 B
JavaScript
import Pagination from '../models/pagination.js'
|
|
import { userList } from '../models/users.js'
|
|
|
|
export async function userListController(req, res) {
|
|
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')
|
|
}
|
|
}
|