summaryrefslogtreecommitdiff
path: root/api.js
diff options
context:
space:
mode:
Diffstat (limited to 'api.js')
-rw-r--r--api.js28
1 files changed, 21 insertions, 7 deletions
diff --git a/api.js b/api.js
index 24c9a9a..a5d42af 100644
--- a/api.js
+++ b/api.js
@@ -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 () => {