diff --git a/src/routes/getBranding.ts b/src/routes/getBranding.ts index 82b67aa..66cc395 100644 --- a/src/routes/getBranding.ts +++ b/src/routes/getBranding.ts @@ -131,21 +131,21 @@ export async function getVideoBrandingByHash(videoHashPrefix: VideoIDHash, servi }; }; - (await branding.titles).map((title) => { + (await branding.titles).forEach((title) => { title.title = title.title.replace("<", "‹"); - + initResult(title); dbResult[title.videoID].titles.push(title); }); - (await branding.thumbnails).map((thumbnail) => { + (await branding.thumbnails).forEach((thumbnail) => { initResult(thumbnail); dbResult[thumbnail.videoID].thumbnails.push(thumbnail); }); - - (await branding.segments).map((segment) => { + + (await branding.segments).forEach((segment) => { initResult(segment); dbResult[segment.videoID].segments.push(segment); - }); + }); return dbResult; }, brandingHashKey(videoHashPrefix, service)); diff --git a/src/utils/createMemoryCache.ts b/src/utils/createMemoryCache.ts index ded7c0b..0215657 100644 --- a/src/utils/createMemoryCache.ts +++ b/src/utils/createMemoryCache.ts @@ -23,9 +23,7 @@ export function createMemoryCache(memoryFn: (...args: any[]) => void, cacheTimeM } } // create new promise - const promise = new Promise((resolve) => { - resolve(memoryFn(...args)); - }); + const promise = Promise.resolve(memoryFn(...args)); // store promise reference until fulfilled promiseMemory.set(cacheKey, promise); return promise.then(result => { diff --git a/src/utils/redis.ts b/src/utils/redis.ts index 3a495e7..9b93a18 100644 --- a/src/utils/redis.ts +++ b/src/utils/redis.ts @@ -26,16 +26,17 @@ interface RedisSB { } let exportClient: RedisSB = { - get: () => new Promise((resolve) => resolve(null)), - set: () => new Promise((resolve) => resolve(null)), - setEx: () => new Promise((resolve) => resolve(null)), - del: () => new Promise((resolve) => resolve(null)), - increment: () => new Promise((resolve) => resolve(null)), - sendCommand: () => new Promise((resolve) => resolve(null)), - quit: () => new Promise((resolve) => resolve(null)), - ttl: () => new Promise((resolve) => resolve(null)), + get: () => Promise.resolve(null), + set: () => Promise.resolve(null), + setEx: () => Promise.resolve(null), + del: () => Promise.resolve(null), + increment: () => Promise.resolve(null), + sendCommand: () => Promise.resolve(null), + quit: () => Promise.resolve(null), + ttl: () => Promise.resolve(null), }; + let lastClientFail = 0; let lastReadFail = 0; let activeRequests = 0;