refactor: make components more modular

would help in implementing name route

also did some stylistic changes
This commit is contained in:
zyachel
2023-04-15 20:56:15 +05:30
parent 8ce02d0236
commit 18ca98fd4a
43 changed files with 757 additions and 796 deletions

View File

@ -1,11 +1,15 @@
/* eslint-disable no-unused-vars */
import Redis from 'ioredis';
const redisUrl = process.env.REDIS_URL;
const toUseRedis = process.env.USE_REDIS === 'true';
let redis: Redis | null;
const stub: Pick<Redis, 'get' | 'setex' | 'getBuffer'> = {
get: async key => Promise.resolve(null),
setex: async (key, seconds, value) => Promise.resolve('OK'),
getBuffer: (key, callback) => Promise.resolve(null),
};
if (toUseRedis && redisUrl) redis = new Redis(redisUrl);
else redis = null;
const redis = toUseRedis && redisUrl ? new Redis(redisUrl) : stub;
export default redis;