This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { Hunts, Packages, Scans } = require('../models');
|
||||
|
||||
// ─── Hunt profile ─────────────────────────────────────────
|
||||
router.get('/hunt/:shortName', (req, res) => {
|
||||
const hunt = Hunts.findByShortName(req.params.shortName);
|
||||
if (!hunt) {
|
||||
return res.status(404).render('error', { title: 'Not Found', message: 'Hunt not found.' });
|
||||
}
|
||||
|
||||
const packages = Packages.getByHunt(hunt.id);
|
||||
const isExpired = Hunts.isExpired(hunt);
|
||||
|
||||
res.render('hunt/profile', { title: hunt.name, hunt, packages, isExpired });
|
||||
});
|
||||
|
||||
// ─── Hunt leaderboard ─────────────────────────────────────
|
||||
router.get('/hunt/:shortName/leaderboard', (req, res) => {
|
||||
const hunt = Hunts.findByShortName(req.params.shortName);
|
||||
if (!hunt) {
|
||||
return res.status(404).render('error', { title: 'Not Found', message: 'Hunt not found.' });
|
||||
}
|
||||
|
||||
const leaderboard = Hunts.getLeaderboard(hunt.id);
|
||||
res.render('hunt/leaderboard', { title: `${hunt.name} - Leaderboard`, hunt, leaderboard });
|
||||
});
|
||||
|
||||
// ─── Global leaderboard ──────────────────────────────────
|
||||
router.get('/leaderboard', (req, res) => {
|
||||
const leaderboard = Scans.getGlobalLeaderboard();
|
||||
res.render('leaderboard/global', { title: 'Global Leaderboard', leaderboard });
|
||||
});
|
||||
|
||||
// ─── Browse all hunts ─────────────────────────────────────
|
||||
router.get('/hunts', (req, res) => {
|
||||
const hunts = Hunts.getAll();
|
||||
res.render('hunt/list', { title: 'All Hunts', hunts });
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user