ddstats-server/routes/routes.js

34 lines
912 B
JavaScript

import { Router } from 'express'
import wrapper from '../libs/database/wrapper.js'
import tx from '../libs/routex.js'
const routes = Router()
routes.get(
'/',
(req, res) => {
tx(req, res)('pages/landing.njk', null, { currentSection: null })
}
)
routes.get(
'/maps',
(req, res) => {
const maps = wrapper.allMaps()
tx(req, res)('pages/maps.njk', { maps }, { currentSection: "maps" })
}
)
routes.get(
'/maps/:map',
(req, res) => {
const map = wrapper.map(req.params.map)
const graphMap = wrapper.graphMap(req.params.map)
const raceLeaderboard = wrapper.leaderboardRace(req.params.map, 1, 10)
const teamLeaderboard = wrapper.leaderboardTeamrace(req.params.map, 1, 10)
tx(req, res)('pages/mapSingle.njk', { map, graphMap, raceLeaderboard, teamLeaderboard }, { currentSection: "maps" })
}
)
export default routes