diff --git a/dev/cassandraRandom.js b/dev/cassandraRandom.js index 7d77ae7fe..0a0ea92a4 100644 --- a/dev/cassandraRandom.js +++ b/dev/cassandraRandom.js @@ -10,15 +10,15 @@ let haveRows = 0; async function start() { // Get the current max_match_id from postgres, subtract 200000000 - let max = (await db.raw(`select max(match_id) from public_matches`)) + const max = (await db.raw("select max(match_id) from public_matches")) ?.rows?.[0]?.max; - let limit = max - 200000000; + const limit = max - 200000000; while (true) { // Test a random match ID const rand = randomInteger(1, limit); - let result = await cassandra.execute( - `select match_id, player_slot, stuns from player_matches where match_id = ?`, + const result = await cassandra.execute( + "select match_id, player_slot, stuns from player_matches where match_id = ?", [rand.toString()], { prepare: true, diff --git a/index.js b/index.js index 845e5cb1e..d8e8835b7 100644 --- a/index.js +++ b/index.js @@ -12,7 +12,7 @@ const group = args[0] || process.env.GROUP; if (process.env.PROVIDER === "gce") { cp.execSync( - 'curl -H "Metadata-Flavor: Google" -L http://metadata.google.internal/computeMetadata/v1/project/attributes/env > /usr/src/.env' + "curl -H \"Metadata-Flavor: Google\" -L http://metadata.google.internal/computeMetadata/v1/project/attributes/env > /usr/src/.env" ); } if (process.env.ROLE) { diff --git a/routes/generateOperationId.js b/routes/generateOperationId.js index e4a51e649..c094e539a 100644 --- a/routes/generateOperationId.js +++ b/routes/generateOperationId.js @@ -1,4 +1,4 @@ -/*This function will create operation IDs in the format: +/* This function will create operation IDs in the format: `get_players_by_account_id` for the path: "/players/{account_id}" `get_players_by_account_id_select_matches` for the path: "/players/{account_id}/matches". */ @@ -20,7 +20,7 @@ function generateOperationId(method, path) { // If there are 3 elements in the path, prefix the last one with "select_" if (segmentsWithParametersReplaced.length === 3) { segmentsWithParametersReplaced[2] = - "select_" + segmentsWithParametersReplaced[2]; + `select_${ segmentsWithParametersReplaced[2]}`; } // Join all segments with underscores diff --git a/routes/keyManagement.js b/routes/keyManagement.js index ad698b661..f90573ced 100644 --- a/routes/keyManagement.js +++ b/routes/keyManagement.js @@ -217,7 +217,7 @@ keys return res.sendStatus(200); } // returning customer - else if (allKeyRecords.length > 0) { + if (allKeyRecords.length > 0) { customer_id = allKeyRecords[0].customer_id; const invoices = await getOpenInvoices(customer_id); diff --git a/routes/responses/schemas/hero/HeroStatsResponse.js b/routes/responses/schemas/hero/HeroStatsResponse.js index b0c0a7e03..ec6facb1f 100644 --- a/routes/responses/schemas/hero/HeroStatsResponse.js +++ b/routes/responses/schemas/hero/HeroStatsResponse.js @@ -131,7 +131,7 @@ module.exports = { description: "night_vision", type: "integer", }, - hero_id: commonProperties.hero_id, //TODO: Duplicate + hero_id: commonProperties.hero_id, // TODO: Duplicate turbo_picks: { description: "Picks in Turbo mode this month", type: "integer", @@ -216,7 +216,7 @@ module.exports = { description: "Immortal wins", type: "integer", }, - //TODO: Should the following remain in the response? + // TODO: Should the following remain in the response? null_pick: { description: "null_pick", type: "integer", diff --git a/routes/spec.js b/routes/spec.js index f00c7f3da..58b8c263c 100644 --- a/routes/spec.js +++ b/routes/spec.js @@ -92,9 +92,9 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque }, ], components: { - securitySchemes: securitySchemes, - schemas: schemas, - parameters: parameters, + securitySchemes, + schemas, + parameters, }, paths: { "/matches/{match_id}": { @@ -264,7 +264,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque content: { "application/json; charset=utf-8": { schema: { - $ref: `#/components/schemas/PlayerWinLossResponse`, + $ref: "#/components/schemas/PlayerWinLossResponse", }, }, }, @@ -384,7 +384,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque parameters: [ ...playerParams, { - $ref: `#/components/parameters/projectParam`, + $ref: "#/components/parameters/projectParam", }, ], responses: { @@ -395,7 +395,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/PlayerMatchesResponse`, + $ref: "#/components/schemas/PlayerMatchesResponse", }, }, }, @@ -451,7 +451,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/PlayerHeroesResponse`, + $ref: "#/components/schemas/PlayerHeroesResponse", }, }, }, @@ -551,7 +551,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/PlayerPeersResponse`, + $ref: "#/components/schemas/PlayerPeersResponse", }, }, }, @@ -614,7 +614,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/PlayerProsResponse`, + $ref: "#/components/schemas/PlayerProsResponse", }, }, }, @@ -670,7 +670,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/PlayerTotalsResponse`, + $ref: "#/components/schemas/PlayerTotalsResponse", }, }, }, @@ -778,7 +778,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque parameters: [ ...playerParams, { - $ref: `#/components/parameters/fieldParam`, + $ref: "#/components/parameters/fieldParam", }, ], responses: { @@ -857,7 +857,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque content: { "application/json; charset=utf-8": { schema: { - $ref: `#/components/schemas/PlayerWardMapResponse`, + $ref: "#/components/schemas/PlayerWardMapResponse", }, }, }, @@ -906,7 +906,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque content: { "application/json; charset=utf-8": { schema: { - $ref: `#/components/schemas/PlayerWordCloudResponse`, + $ref: "#/components/schemas/PlayerWordCloudResponse", }, }, }, @@ -957,7 +957,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/PlayerRatingsResponse`, + $ref: "#/components/schemas/PlayerRatingsResponse", }, }, }, @@ -1066,7 +1066,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/PlayerObjectResponse`, + $ref: "#/components/schemas/PlayerObjectResponse", }, }, }, @@ -1107,7 +1107,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/MatchObjectResponse`, + $ref: "#/components/schemas/MatchObjectResponse", }, }, }, @@ -1166,7 +1166,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/PublicMatchesResponse`, + $ref: "#/components/schemas/PublicMatchesResponse", }, }, }, @@ -1188,10 +1188,10 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque order = "ORDER BY match_id DESC"; moreThan = 0; } - let minRank = req.query.min_rank + const minRank = req.query.min_rank ? `AND avg_rank_tier >= ${req.query.min_rank}` : ""; - let maxRank = req.query.max_rank + const maxRank = req.query.max_rank ? `AND avg_rank_tier <= ${req.query.max_rank}` : ""; @@ -1241,7 +1241,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/ParsedMatchesResponse`, + $ref: "#/components/schemas/ParsedMatchesResponse", }, }, }, @@ -1317,9 +1317,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque err = e; } client.end(); - const final = Object.assign({}, result, { - err: err && err.toString(), - }); + const final = { ...result, err: err && err.toString(),}; return res.status(err ? 400 : 200).json(final); }, }, @@ -1336,7 +1334,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque content: { "application/json; charset=utf-8": { schema: { - $ref: `#/components/schemas/MetadataResponse`, + $ref: "#/components/schemas/MetadataResponse", }, }, }, @@ -1365,7 +1363,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque content: { "application/json; charset=utf-8": { schema: { - $ref: `#/components/schemas/DistributionsResponse`, + $ref: "#/components/schemas/DistributionsResponse", }, }, }, @@ -1407,7 +1405,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/SearchResponse`, + $ref: "#/components/schemas/SearchResponse", }, }, }, @@ -1453,7 +1451,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque description: "Hero ID", required: true, schema: { - type: "string", //todo: String for hero id? + type: "string", // todo: String for hero id? }, }, ], @@ -1463,7 +1461,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque content: { "application/json; charset=utf-8": { schema: { - $ref: `#/components/schemas/RankingsResponse`, + $ref: "#/components/schemas/RankingsResponse", }, }, }, @@ -1509,7 +1507,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque content: { "application/json; charset=utf-8": { schema: { - $ref: `#/components/schemas/BenchmarksResponse`, + $ref: "#/components/schemas/BenchmarksResponse", }, }, }, @@ -1640,9 +1638,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque } if (job) { return res.json( - Object.assign({}, job, { - jobId: job.id, - }) + { ...job, jobId: job.id,} ); } return res.json(null); @@ -1824,7 +1820,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/HeroObjectResponse`, + $ref: "#/components/schemas/HeroObjectResponse", }, }, }, @@ -1860,7 +1856,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/HeroStatsResponse`, + $ref: "#/components/schemas/HeroStatsResponse", }, }, }, @@ -1894,7 +1890,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/MatchObjectResponse`, + $ref: "#/components/schemas/MatchObjectResponse", }, }, }, @@ -1950,7 +1946,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/HeroMatchupsResponse`, + $ref: "#/components/schemas/HeroMatchupsResponse", }, }, }, @@ -1997,7 +1993,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/HeroDurationsResponse`, + $ref: "#/components/schemas/HeroDurationsResponse", }, }, }, @@ -2041,9 +2037,9 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - type: "array", //todo: Why double array? + type: "array", // todo: Why double array? items: { - $ref: `#/components/schemas/PlayerObjectResponse`, + $ref: "#/components/schemas/PlayerObjectResponse", }, }, }, @@ -2091,7 +2087,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque content: { "application/json; charset=utf-8": { schema: { - $ref: `#/components/schemas/HeroItemPopularityResponse`, + $ref: "#/components/schemas/HeroItemPopularityResponse", }, }, }, @@ -2129,7 +2125,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/LeagueObjectResponse`, + $ref: "#/components/schemas/LeagueObjectResponse", }, }, }, @@ -2164,7 +2160,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/LeagueObjectResponse`, + $ref: "#/components/schemas/LeagueObjectResponse", }, }, }, @@ -2200,7 +2196,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque content: { "application/json; charset=utf-8": { schema: { - $ref: `#/components/schemas/MatchObjectResponse`, + $ref: "#/components/schemas/MatchObjectResponse", }, }, }, @@ -2362,7 +2358,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque content: { "application/json; charset=utf-8": { schema: { - $ref: `#/components/schemas/TeamMatchObjectResponse`, + $ref: "#/components/schemas/TeamMatchObjectResponse", }, }, }, @@ -2404,7 +2400,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque content: { "application/json; charset=utf-8": { schema: { - $ref: `#/components/schemas/TeamPlayersResponse`, + $ref: "#/components/schemas/TeamPlayersResponse", }, }, }, @@ -2445,7 +2441,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque content: { "application/json; charset=utf-8": { schema: { - $ref: `#/components/schemas/TeamHeroesResponse`, + $ref: "#/components/schemas/TeamHeroesResponse", }, }, }, @@ -2488,7 +2484,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/ReplaysResponse`, + $ref: "#/components/schemas/ReplaysResponse", }, }, }, @@ -2537,7 +2533,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/RecordsResponse`, + $ref: "#/components/schemas/RecordsResponse", }, }, }, @@ -2631,7 +2627,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque { name: "item", in: "query", - description: 'Filter by item name e.g. "spirit_vessel"', + description: "Filter by item name e.g. \"spirit_vessel\"", required: false, schema: { type: "string", @@ -2647,7 +2643,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/ScenarioItemTimingsResponse`, + $ref: "#/components/schemas/ScenarioItemTimingsResponse", }, }, }, @@ -2691,7 +2687,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/ScenarioLaneRolesResponse`, + $ref: "#/components/schemas/ScenarioLaneRolesResponse", }, }, }, @@ -2724,7 +2720,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/ScenarioMiscResponse`, + $ref: "#/components/schemas/ScenarioMiscResponse", }, }, }, @@ -2757,7 +2753,7 @@ The OpenDota API offers 50,000 free calls per month and a rate limit of 60 reque schema: { type: "array", items: { - $ref: `#/components/schemas/SchemaResponse`, + $ref: "#/components/schemas/SchemaResponse", }, }, }, diff --git a/store/buildMatch.js b/store/buildMatch.js index d92d941e8..b400fbc16 100644 --- a/store/buildMatch.js +++ b/store/buildMatch.js @@ -7,9 +7,9 @@ const config = require("../config"); const queries = require("./queries"); const compute = require("../util/compute"); const utility = require("../util/utility"); -const cassandra = require("../store/cassandra"); -const redis = require("../store/redis"); -const db = require("../store/db"); +const cassandra = require("./cassandra"); +const redis = require("./redis"); +const db = require("./db"); const { computeMatchData } = compute; const { deserialize, buildReplayUrl, isContributor } = utility; diff --git a/store/queries.js b/store/queries.js index b58f12ca7..749612ad6 100644 --- a/store/queries.js +++ b/store/queries.js @@ -10,10 +10,10 @@ const queue = require("./queue"); const su = require("../util/scenariosUtil"); const filter = require("../util/filter"); const compute = require("../util/compute"); -const db = require("../store/db"); -const redis = require("../store/redis"); -const { es, INDEX } = require("../store/elasticsearch"); -const cassandra = require("../store/cassandra"); +const db = require("./db"); +const redis = require("./redis"); +const { es, INDEX } = require("./elasticsearch"); +const cassandra = require("./cassandra"); const cacheFunctions = require("./cacheFunctions"); const benchmarksUtil = require("../util/benchmarksUtil"); @@ -629,7 +629,7 @@ function getProPeers(db, input, player, cb) { return cb(err); } const arr = result.rows - .map((r) => Object.assign({}, r, teammates[r.account_id])) + .map((r) => ({ ...r, ...teammates[r.account_id]})) .filter((r) => r.account_id !== player.account_id && r.games) .sort((a, b) => b.games - a.games); return cb(err, arr); @@ -1054,9 +1054,7 @@ function insertMatch(match, options, cb) { p.ability_upgrades.forEach((au) => { if (au.ability in savedAbilityLvls) { abilityLvls[au.ability] = (abilityLvls[au.ability] || 0) + 1; - const abilityUpgrade = Object.assign({}, au, { - level: abilityLvls[au.ability], - }); + const abilityUpgrade = { ...au, level: abilityLvls[au.ability],}; abilityUpgrades.push(abilityUpgrade); } }); @@ -1677,7 +1675,7 @@ function getMetadata(req, callback) { isSubscriber(cb) { if (req.user) { db.raw( - `SELECT account_id from subscriber WHERE account_id = ? AND status = 'active'`, + "SELECT account_id from subscriber WHERE account_id = ? AND status = 'active'", [req.user.account_id] ).asCallback((err, result) => { cb(err, Boolean(result?.rows?.[0])); diff --git a/svc/apiadmin.js b/svc/apiadmin.js index 7d08ab93e..eeac99426 100644 --- a/svc/apiadmin.js +++ b/svc/apiadmin.js @@ -170,7 +170,7 @@ async function updateStripeUsage(cb) { } } -invokeInterval(function updateAPIKeysInRedis(cb) { +invokeInterval((cb) => { queries.getAPIKeys(db, (err, rows) => { if (err) { cb(err); @@ -194,7 +194,7 @@ invokeInterval(function updateAPIKeysInRedis(cb) { }); }, 5 * 60 * 1000); // Update every 5 min -invokeInterval(function runStoreUsageCounts(cb) { +invokeInterval((cb) => { storeUsageCounts(0, cb); }, 10 * 60 * 1000); // Every 10 minutes invokeInterval(updateStripeUsage, 5 * 60 * 1000); // Every 5 minutes diff --git a/svc/cassandraDelete.js b/svc/cassandraDelete.js index 4358755ac..1e13cea6d 100644 --- a/svc/cassandraDelete.js +++ b/svc/cassandraDelete.js @@ -1,9 +1,9 @@ +const crypto = require("crypto"); const cassandra = require("../store/cassandra"); const db = require("../store/db"); -const crypto = require("crypto"); function genRandomNumber(byteCount, radix) { - return BigInt("0x" + crypto.randomBytes(byteCount).toString("hex")).toString( + return BigInt(`0x${ crypto.randomBytes(byteCount).toString("hex")}`).toString( radix ); } @@ -12,17 +12,17 @@ const PARSED_DATA_DELETE_ID = 0; async function start() { // Get the current max_match_id from postgres, subtract 200000000 - let max = (await db.raw(`select max(match_id) from public_matches`)) + const max = (await db.raw("select max(match_id) from public_matches")) ?.rows?.[0]?.max; - let limit = max - 200000000; + const limit = max - 200000000; while (true) { // delete older unparsed match/player_match rows // We can backfill these from Steam API on demand try { // Convert to signed bigint const randomBigint = BigInt.asIntN(64, genRandomNumber(8, 10)); - let result = await cassandra.execute( - `select match_id, version, token(match_id) from matches where token(match_id) >= ? limit 500 ALLOW FILTERING;`, + const result = await cassandra.execute( + "select match_id, version, token(match_id) from matches where token(match_id) >= ? limit 500 ALLOW FILTERING;", [randomBigint.toString()], { prepare: true, @@ -32,7 +32,7 @@ async function start() { ); // Put the ones that don't have parsed data or are too old into an array - let ids = result.rows + const ids = result.rows .filter( (result) => (result.version == null || @@ -51,7 +51,7 @@ async function start() { // Delete matches await Promise.all( ids.map((id) => - cassandra.execute(`DELETE from matches where match_id = ?`, [id], { + cassandra.execute("DELETE from matches where match_id = ?", [id], { prepare: true, }) ) @@ -60,7 +60,7 @@ async function start() { await Promise.all( ids.map((id) => cassandra.execute( - `DELETE from player_matches where match_id = ?`, + "DELETE from player_matches where match_id = ?", [id], { prepare: true, @@ -69,7 +69,7 @@ async function start() { ) ); const parsedIds = result.rows.filter(result => result.version != null).map(result => result.match_id); - await Promise.all(parsedIds.map(id => db.raw(`INSERT INTO parsed_matches(match_id) VALUES(?) ON CONFLICT DO NOTHING`, [Number(id)]))); + await Promise.all(parsedIds.map(id => db.raw("INSERT INTO parsed_matches(match_id) VALUES(?) ON CONFLICT DO NOTHING", [Number(id)]))); } catch (e) { console.log(e); } diff --git a/svc/retriever.js b/svc/retriever.js index 87f30dad5..f7b519fa3 100644 --- a/svc/retriever.js +++ b/svc/retriever.js @@ -423,9 +423,9 @@ app.use(compression()); app.get("/healthz", (req, res, cb) => { if (!allReady) { return cb("not ready"); - } else { + } return res.end("ok"); - } + }); app.use((req, res, cb) => { if (config.RETRIEVER_SECRET && config.RETRIEVER_SECRET !== req.query.key) { diff --git a/svc/web.js b/svc/web.js index 6a7c409ce..dcc5cc278 100644 --- a/svc/web.js +++ b/svc/web.js @@ -11,6 +11,8 @@ const express = require("express"); const passport = require("passport"); const SteamStrategy = require("passport-steam").Strategy; const cors = require("cors"); +const bodyParser = require("body-parser"); +const stripe = require("stripe")(config.STRIPE_SECRET); const keys = require("../routes/keyManagement"); const api = require("../routes/api"); const queries = require("../store/queries"); @@ -18,8 +20,6 @@ const db = require("../store/db"); const redis = require("../store/redis"); const utility = require("../util/utility"); const config = require("../config"); -const bodyParser = require("body-parser"); -const stripe = require("stripe")(config.STRIPE_SECRET); const { redisCount } = utility; @@ -142,7 +142,7 @@ app.use((req, res, cb) => { }); app.set("trust proxy", true); app.use((req, res, cb) => { - const ip = req.ip; + const {ip} = req; res.locals.ip = ip; let rateLimit = ""; @@ -326,14 +326,14 @@ app.route("/subscribeSuccess").get(async (req, res) => { [accountId, customer.id, "active"] ); // Send the user back to the subscribe page - return res.redirect(config.UI_HOST + "/subscribe"); + return res.redirect(`${config.UI_HOST }/subscribe`); }); app.route("/manageSub").post(async (req, res) => { if (!req.user?.account_id) { return res.status(400).json({ error: "no account ID" }); } const result = await db.raw( - `SELECT customer_id FROM subscriber where account_id = ? AND status = 'active'`, + "SELECT customer_id FROM subscriber where account_id = ? AND status = 'active'", [req.user.account_id] ); diff --git a/util/getGcData.js b/util/getGcData.js index 0a0b6fc01..b3546b734 100644 --- a/util/getGcData.js +++ b/util/getGcData.js @@ -3,12 +3,12 @@ * Calls back with an object containing the GC data * */ const moment = require("moment"); -const utility = require("../util/utility"); +const { promisify } = require("util"); +const utility = require("./utility"); const config = require("../config"); const queries = require("../store/queries"); const db = require("../store/db"); const redis = require("../store/redis"); -const { promisify } = require("util"); const secret = config.RETRIEVER_SECRET; const { getData, redisCount } = utility; @@ -17,7 +17,7 @@ const { insertMatch } = queries; async function getGcDataFromRetriever(match, cb) { const retrieverArr = utility.getRetrieverArr(match.useGcDataArr); // make array of retriever urls and use a random one on each retry - let urls = retrieverArr.map( + const urls = retrieverArr.map( (r) => `http://${r}?key=${secret}&match_id=${match.match_id}` ); return getData( @@ -37,7 +37,7 @@ async function getGcDataFromRetriever(match, cb) { } // Count retriever calls redisCount(redis, "retriever"); - redis.zincrby("retrieverCounts", 1, 'retriever'); + redis.zincrby("retrieverCounts", 1, "retriever"); redis.expireat( "retrieverCounts", moment().startOf("hour").add(1, "hour").format("X") @@ -89,7 +89,7 @@ module.exports = async function getGcData(match, cb) { } // Check if we have it in DB already const saved = await db.raw( - `select match_id, cluster, replay_salt from match_gcdata where match_id = ?`, + "select match_id, cluster, replay_salt from match_gcdata where match_id = ?", [match.match_id] ); const gcdata = saved.rows[0];