2021-01-18 21:54:18 -05:00
|
|
|
let cache = {}
|
2021-07-07 20:58:31 -04:00
|
|
|
let gauntletNames = ["Fire", "Ice", "Poison", "Shadow", "Lava", "Bonus", "Chaos", "Demon", "Time", "Crystal", "Magic", "Spike", "Monster", "Doom", "Death"]
|
2021-01-15 10:29:46 -05:00
|
|
|
|
|
|
|
module.exports = async (app, req, res) => {
|
|
|
|
|
2021-12-07 14:14:56 -05:00
|
|
|
if (req.offline) return res.sendError()
|
2021-01-18 21:54:18 -05:00
|
|
|
|
|
|
|
let cached = cache[req.id]
|
2022-02-06 19:18:45 -05:00
|
|
|
if (app.config.cacheGauntlets && cached && cached.data && cached.indexed + 2000000 > Date.now()) return res.send(cached.data) // half hour cache
|
2021-01-15 10:29:46 -05:00
|
|
|
|
2021-01-18 21:54:18 -05:00
|
|
|
req.gdRequest('getGJGauntlets21', {}, function (err, resp, body) {
|
2021-01-15 10:29:46 -05:00
|
|
|
|
2021-12-07 14:14:56 -05:00
|
|
|
if (err) return res.sendError()
|
2021-01-22 22:28:26 -05:00
|
|
|
let gauntlets = body.split('#')[0].split('|').map(x => app.parseResponse(x)).filter(x => x[3])
|
2021-07-07 20:58:31 -04:00
|
|
|
let gauntletList = gauntlets.map(x => ({ id: +x[1], name: gauntletNames[+x[1] - 1] || "Unknown", levels: x[3].split(",") }))
|
2021-01-15 10:29:46 -05:00
|
|
|
|
2021-01-18 21:54:18 -05:00
|
|
|
if (app.config.cacheGauntlets) cache[req.id] = {data: gauntletList, indexed: Date.now()}
|
2022-02-06 19:18:45 -05:00
|
|
|
res.send(gauntletList)
|
2021-01-15 10:29:46 -05:00
|
|
|
|
|
|
|
})
|
|
|
|
|
2021-01-18 21:54:18 -05:00
|
|
|
}
|