diff options
Diffstat (limited to 'api.js')
| -rw-r--r-- | api.js | 28 |
1 files changed, 21 insertions, 7 deletions
@@ -66,13 +66,23 @@ function subscribe(topic, channel) { async function getMappings() { return await cache.wrap("mappings", async () => { let mapping = new Map(); - await Promise.map( - ["gamemode"], async (table) => { - mapping[table] = new Map(); - (await getMap(table)).map( - (map) => mapping[table][map["id"]] = map["name"]) - } - ); + await Promise.all([ + Promise.map( + ["gamemode"], async (table) => { + mapping[table] = new Map(); + (await getMap(table)).map( + (map) => mapping[table][map["id"]] = map["name"]) + } + ), + // name <-> API name + Promise.map( + ["hero"], async (table) => { + mapping[table] = new Map(); + (await getMap(table)).map( + (map) => mapping[table][map["api_name"]] = map["name"]) + } + ) + ]); return mapping; }, { ttl: 60 * 30 }); } @@ -81,6 +91,10 @@ module.exports.mapGameMode = async function(id) { return (await getMappings())["gamemode"][id]; } +module.exports.mapActor = async function(api_name) { + return (await getMappings())["hero"][api_name]; +} + // return a set of IGN of supporters module.exports.getGamers = async function() { return await cache.wrap("gamers", async () => { |
