convert analytics to TS

This commit is contained in:
chreamy committed 2024-02-26 20:23:03 -06:00
1 parent 9509bbc355
commit ece0ec7c41
25 files changed
+11595 -661

No files matched your search

@@ -0,0 +1,24 @@
/* eslint-disable object-shorthand */
import Pagination from '../models/pagination.ts'
import { errorCommands } from '../models/commands.js'
// eslint-disable-next-line import/prefer-default-export
export async function commandListController(req: any, res: any): Promise<void> {
const { nextKey, order } = req.query as { nextKey?: string; order: string }
const itemsPerPage = 100
try {
const pagination = new Pagination(order, itemsPerPage, nextKey)
const payload = await errorCommands(pagination)
const newNextKey = payload[payload.length - 1]?._id
res.render('commands', {
errorCommands: payload,
nextKey: newNextKey,
order: pagination.getOrder(),
})
} catch (error) {
console.error(error)
res.status(500).send('Error fetching data')
}
}