mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
25 lines
764 B
JavaScript
25 lines
764 B
JavaScript
import { sessionCount, sessionList, sessionDetail } from '../models/sessions.js'
|
|
|
|
export async function sessionListController(req, res) {
|
|
const { nextKey } = req.query
|
|
const itemsPerPage = 100
|
|
|
|
try {
|
|
// const totalSessions = await sessionCount()
|
|
// const maxPages = Math.ceil(totalSessions / itemsPerPage)
|
|
|
|
const sessions = await sessionList({ nextKey, itemsPerPage })
|
|
const newNextKey = sessions[sessions.length - 1]?._id
|
|
|
|
res.render('sessions', { sessions, nextKey: newNextKey })
|
|
} catch (error) {
|
|
res.status(500).send('Error fetching session data')
|
|
}
|
|
}
|
|
|
|
export async function sessionDetailController(req, res) {
|
|
const { id } = req.params
|
|
const session = await sessionDetail(id)
|
|
res.render('sessionDetail', { session })
|
|
}
|