mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-08 19:16:37 +08:00
redis env 2
This commit is contained in:
parent
9496f6bb4d
commit
83ed6bfc0b
@ -1,18 +1,20 @@
|
|||||||
// redisRestClient.ts
|
// redisRestClient.ts
|
||||||
import { Redis } from "@upstash/redis";
|
import { Redis } from "@upstash/redis";
|
||||||
|
|
||||||
const redisUrl = process.env.UPSTASH_REDIS_URL ?? "";
|
// Check if the environment variables are set
|
||||||
const redisToken = process.env.UPSTASH_REDIS_REST_TOKEN ?? "";
|
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({
|
const redis = new Redis({
|
||||||
url: redisUrl,
|
url: redisUrl,
|
||||||
token: redisToken,
|
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) => {
|
export const incrementSignInCount = async (email: string | undefined, dateKey: string) => {
|
||||||
if (!email) {
|
if (!email) {
|
||||||
|
Loading…
Reference in New Issue
Block a user