mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-27 22:25:58 +02:00
Merge branch 'dev' of https://github.com/fosrl/pangolin into dev
This commit is contained in:
commit
379d31aac6
234 changed files with 16088 additions and 7588 deletions
16
server/lib/rateLimitStore.ts
Normal file
16
server/lib/rateLimitStore.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { MemoryStore, Store } from "express-rate-limit";
|
||||
import config from "./config";
|
||||
import redisManager from "@server/db/redis";
|
||||
import { RedisStore } from "rate-limit-redis";
|
||||
|
||||
export function createStore(): Store {
|
||||
let rateLimitStore: Store = new MemoryStore();
|
||||
if (config.getRawConfig().flags?.enable_redis) {
|
||||
const client = redisManager.client!;
|
||||
rateLimitStore = new RedisStore({
|
||||
sendCommand: async (command: string, ...args: string[]) =>
|
||||
(await client.call(command, args)) as any
|
||||
});
|
||||
}
|
||||
return rateLimitStore;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue