From 83ed6bfc0b6453de03543c2661b11d25030d35fb Mon Sep 17 00:00:00 2001 From: DirkSchlossmacher <62424946+DirkSchlossmacher@users.noreply.github.com> Date: Mon, 13 Nov 2023 15:18:57 +0100 Subject: [PATCH] redis env 2 --- app/utils/cloud/redisRestClient.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/utils/cloud/redisRestClient.ts b/app/utils/cloud/redisRestClient.ts index 7daf3aa73..726dfb730 100644 --- a/app/utils/cloud/redisRestClient.ts +++ b/app/utils/cloud/redisRestClient.ts @@ -1,18 +1,20 @@ // redisRestClient.ts import { Redis } from "@upstash/redis"; -const redisUrl = process.env.UPSTASH_REDIS_URL ?? ""; -const redisToken = process.env.UPSTASH_REDIS_REST_TOKEN ?? ""; +// Check if the environment variables are set +const redisUrl = process.env.UPSTASH_REDIS_URL; +const redisToken = process.env.UPSTASH_REDIS_REST_TOKEN; +if (!redisUrl || !redisToken) { + throw new Error('The Upstash Redis URL and token must be provided.'); +} + +// Create the Redis instance with the known-to-be-defined values const redis = new Redis({ url: redisUrl, token: redisToken, }); -if (!redis.url || !redis.token) { - console.error('The Upstash Redis URL and token must be provided.'); - // Handle the lack of Redis client here, e.g., by disabling certain features -} export const incrementSignInCount = async (email: string | undefined, dateKey: string) => { if (!email) {