revert type fix
This commit is contained in:
parent
67eb895988
commit
be3b855760
2 changed files with 13 additions and 14 deletions
|
@ -1,7 +1,7 @@
|
||||||
import Redis from "ioredis";
|
import RedisInstance from "ioredis";
|
||||||
|
|
||||||
async function applyCache(
|
async function applyCache(
|
||||||
redis: Redis,
|
redis: RedisInstance,
|
||||||
key: string,
|
key: string,
|
||||||
query: string,
|
query: string,
|
||||||
gql: boolean,
|
gql: boolean,
|
||||||
|
@ -19,7 +19,7 @@ async function applyCache(
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchEndpoint(
|
async function fetchEndpoint(
|
||||||
redis: Redis,
|
redis: RedisInstance,
|
||||||
query: string,
|
query: string,
|
||||||
gql: boolean = false
|
gql: boolean = false
|
||||||
) {
|
) {
|
||||||
|
@ -53,7 +53,7 @@ async function fetchGQL(query: string) {
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getGlobalEmotes(redis: Redis) {
|
async function getGlobalEmotes(redis: RedisInstance) {
|
||||||
const gqlQuery = `query {
|
const gqlQuery = `query {
|
||||||
namedEmoteSet(name: GLOBAL) {
|
namedEmoteSet(name: GLOBAL) {
|
||||||
emote_count
|
emote_count
|
||||||
|
@ -84,7 +84,7 @@ async function getGlobalEmotes(redis: Redis) {
|
||||||
return await applyCache(redis, "7TV.GLOBAL_EMOTES", gqlQuery, true, 3600);
|
return await applyCache(redis, "7TV.GLOBAL_EMOTES", gqlQuery, true, 3600);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getChannelEmotes(redis: Redis, channelID: string) {
|
async function getChannelEmotes(redis: RedisInstance, channelID: string) {
|
||||||
const gqlQuery = `query {
|
const gqlQuery = `query {
|
||||||
user(id: "${channelID}") {
|
user(id: "${channelID}") {
|
||||||
emote_sets {
|
emote_sets {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
// ioredis types
|
import RedisInstance from "ioredis";
|
||||||
import Redis from "ioredis";
|
|
||||||
|
|
||||||
async function applyCache(
|
async function applyCache(
|
||||||
redis: Redis,
|
redis: RedisInstance,
|
||||||
key: string,
|
key: string,
|
||||||
query: string,
|
query: string,
|
||||||
cacheTime: number
|
cacheTime: number
|
||||||
|
@ -18,7 +17,7 @@ async function applyCache(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function authTwitch(redis: Redis) {
|
async function authTwitch(redis: RedisInstance) {
|
||||||
let auth = await redis.get("TWITCH.AUTH");
|
let auth = await redis.get("TWITCH.AUTH");
|
||||||
if (auth) {
|
if (auth) {
|
||||||
return auth;
|
return auth;
|
||||||
|
@ -36,7 +35,7 @@ async function authTwitch(redis: Redis) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchEndpoint(redis: Redis, query: string) {
|
async function fetchEndpoint(redis: RedisInstance, query: string) {
|
||||||
if (await redis.get("TWITCH.RATE_LIMIT")) {
|
if (await redis.get("TWITCH.RATE_LIMIT")) {
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||||
} else {
|
} else {
|
||||||
|
@ -56,7 +55,7 @@ async function fetchEndpoint(redis: Redis, query: string) {
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getUserByName(redis: Redis, username: string) {
|
async function getUserByName(redis: RedisInstance, username: string) {
|
||||||
return await applyCache(
|
return await applyCache(
|
||||||
redis,
|
redis,
|
||||||
"TWITCH.USER_" + username,
|
"TWITCH.USER_" + username,
|
||||||
|
@ -65,7 +64,7 @@ async function getUserByName(redis: Redis, username: string) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getUserByID(redis: Redis, userID: string) {
|
async function getUserByID(redis: RedisInstance, userID: string) {
|
||||||
return await applyCache(
|
return await applyCache(
|
||||||
redis,
|
redis,
|
||||||
"TWITCH.USER_" + userID,
|
"TWITCH.USER_" + userID,
|
||||||
|
@ -74,7 +73,7 @@ async function getUserByID(redis: Redis, userID: string) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getGlobalEmotes(redis: Redis) {
|
async function getGlobalEmotes(redis: RedisInstance) {
|
||||||
return await applyCache(
|
return await applyCache(
|
||||||
redis,
|
redis,
|
||||||
"TWITCH.GLOBAL_EMOTES",
|
"TWITCH.GLOBAL_EMOTES",
|
||||||
|
@ -83,7 +82,7 @@ async function getGlobalEmotes(redis: Redis) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getChannelEmotes(redis: Redis, channelID: string) {
|
async function getChannelEmotes(redis: RedisInstance, channelID: string) {
|
||||||
return await applyCache(
|
return await applyCache(
|
||||||
redis,
|
redis,
|
||||||
"TWITCH.CHANNEL_EMOTES_" + channelID,
|
"TWITCH.CHANNEL_EMOTES_" + channelID,
|
||||||
|
|
Loading…
Add table
Reference in a new issue