-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
david emioma
committed
Apr 2, 2024
1 parent
5248930
commit 866b2d9
Showing
5 changed files
with
102 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
import { Redis } from "@upstash/redis"; | ||
import Redis from "ioredis"; | ||
import { Ratelimit } from "@upstash/ratelimit"; | ||
import { Redis as RedisClient } from "@upstash/redis"; | ||
|
||
export const redis = new Redis({ | ||
export const redis = new RedisClient({ | ||
url: process.env.UPSTASH_REDIS_REST_URL as string, | ||
token: process.env.UPSTASH_REDIS_REST_TOKEN as string, | ||
}); | ||
|
||
export const apiRatelimit = new Ratelimit({ | ||
redis: redis ?? Redis.fromEnv(), | ||
redis: redis ?? RedisClient.fromEnv(), | ||
limiter: Ratelimit.slidingWindow(10, "1 m"), | ||
}); | ||
|
||
const getRedisUrl = () => { | ||
if (process.env.REDIS_URL) { | ||
return process.env.REDIS_URL as string; | ||
} | ||
|
||
throw new Error("Redis URL not specified!"); | ||
}; | ||
|
||
export const redisServer = new Redis(getRedisUrl()); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters