Files
AnimeTV-Backend/backup/modules/userSession/services/checkUserSessionInCache.service.ts
Rafi Arrafif 8532d7e104 🚚 create backup folder
create backup folder for archive the old modules
2025-07-18 23:20:15 +07:00

20 lines
737 B
TypeScript

import { ErrorForwarder } from "../../../helpers/error/instances/forwarder";
import { checkUserSessionInCacheRepo } from "../repositories/checkUserSessionInCache.repository";
export const checkUserSessionInCacheService = async (
userId: string,
sessionId: string
) => {
try {
// Construct the Redis key name using the userId and sessionId
const redisKeyName = `${process.env.APP_NAME}:users:${userId}:sessions:${sessionId}`;
// Check if the user session exists in Redis
const userSessionInRedis = await checkUserSessionInCacheRepo(redisKeyName);
return userSessionInRedis;
} catch (error) {
// Forward the error with a 400 status code and a message
ErrorForwarder(error, 400, "Bad Request");
}
};