redisRestClient rework

This commit is contained in:
DirkSchlossmacher 2023-11-14 13:03:33 +01:00
parent c93d001be5
commit 4cb13df34f

View File

@ -24,16 +24,19 @@ const getRedisClient = () => {
export const incrementSignInCount = async (email: string | undefined, dateKey: string) => {
export const incrementSignInCount = async (
email: string | undefined,
dateKey: string
): Promise<void> => {
if (!email) {
console.error('Email is undefined, cannot increment sign-in count.');
return;
return; // This is fine for a function returning Promise<void>
}
const redis = getRedisClient();
if (!redis) {
console.error('Redis client is not initialized.');
return;
return; // This is fine for a function returning Promise<void>
}
try {
@ -43,16 +46,19 @@ export const incrementSignInCount = async (email: string | undefined, dateKey: s
}
};
export const incrementSessionRefreshCount = async (email: string | undefined, dateKey: string) => {
export const incrementSessionRefreshCount = async (
email: string | undefined,
dateKey: string
): Promise<void> => {
if (!email) {
console.error('Email is undefined, cannot increment session refresh count.');
return;
return; // This is fine for a function returning Promise<void>
}
const redis = getRedisClient();
if (!redis) {
console.error('Redis client is not initialized.');
return;
return; // This is fine for a function returning Promise<void>
}
try {
@ -62,6 +68,7 @@ export const incrementSessionRefreshCount = async (email: string | undefined, da
}
};
export const incrementTokenCounts = async (
email: string | undefined,
dateKey: string,
@ -93,7 +100,7 @@ export const getAvailableDateKeys = async (): Promise<string[]> => {
const redis = getRedisClient();
if (!redis) {
console.error('Redis client is not initialized.');
return;
return []; // Return an empty array explicitly
}
try {
@ -139,7 +146,7 @@ export const getDetailsByUser = async (dateKey: string): Promise<Record<string,
const redis = getRedisClient();
if (!redis) {
console.error('Redis client is not initialized.');
return;
return {};
}
try {