Merge branch 'main' of https://git.qwik.space/BurnyLlama/ddstats-server
This commit is contained in:
commit
69313e86c7
|
@ -1,10 +1,22 @@
|
||||||
export default function routex(req, res) {
|
export default function routex(req, res) {
|
||||||
if (req.baseUrl === "/api")
|
if (req.baseUrl === "/api")
|
||||||
return function(_, data, _2) {
|
return function(_, data, success, __) {
|
||||||
res.json(data)
|
if (success)
|
||||||
|
return res.json({
|
||||||
|
success,
|
||||||
|
response: data
|
||||||
|
})
|
||||||
|
|
||||||
|
return res.json({
|
||||||
|
success,
|
||||||
|
response: data.error
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return function(template, data, options) {
|
return function(template, data, success, options) {
|
||||||
res.render(template, { data, options })
|
if (success)
|
||||||
|
return res.render(template, { data, options })
|
||||||
|
|
||||||
|
return res.render("pages/error.njk", { data, options })
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,7 +15,7 @@ routes.get(
|
||||||
'/maps',
|
'/maps',
|
||||||
(req, res) => {
|
(req, res) => {
|
||||||
const maps = wrapper.allMaps()
|
const maps = wrapper.allMaps()
|
||||||
tx(req, res)('pages/maps.njk', { maps }, { currentSection: "maps" })
|
tx(req, res)('pages/maps.njk', { maps }, true, { currentSection: "maps" })
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,7 +27,9 @@ routes.get(
|
||||||
const raceLeaderboard = wrapper.leaderboardRace(req.params.map, 1, 10)
|
const raceLeaderboard = wrapper.leaderboardRace(req.params.map, 1, 10)
|
||||||
const teamLeaderboard = wrapper.leaderboardTeamrace(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" })
|
const [success, error] = map ? [true, "No error!"] : [false, "Map not found!"]
|
||||||
|
|
||||||
|
tx(req, res)('pages/mapSingle.njk', { map, graphMap, raceLeaderboard, teamLeaderboard, error }, success, { currentSection: "maps" })
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
22
views/pages/error.njk
Normal file
22
views/pages/error.njk
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{% extends "../templates/basic.njk" %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<main class="flex-container">
|
||||||
|
<div class="error">
|
||||||
|
<h1>
|
||||||
|
We are really sorry about this...
|
||||||
|
</h1>
|
||||||
|
<p>
|
||||||
|
There seems as if you've ran into an error...
|
||||||
|
<br> <br>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h6>
|
||||||
|
Reported error:
|
||||||
|
</h6>
|
||||||
|
<code>
|
||||||
|
{{ data.error }}
|
||||||
|
</code>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user