mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-16 17:49:09 +00:00
feat(api): add rate-limiting and /clear-guild-cache (#198)
This commit is contained in:
parent
57d83699d5
commit
a4fd37d71c
7 changed files with 138 additions and 12 deletions
|
@ -10,6 +10,7 @@ import {
|
|||
import { AuthType, cacheLayer, discordFetch } from './api-tools';
|
||||
import { botClientID, botToken } from './config';
|
||||
import { GuildData, Guilds } from './kv';
|
||||
import { useRateLimiter } from './rate-limiting';
|
||||
|
||||
type APIGuild = {
|
||||
// Only relevant stuff
|
||||
|
@ -161,3 +162,14 @@ const calculateRoleSafety = (role: Role | APIRole, highestBotRolePosition: numbe
|
|||
|
||||
return safety;
|
||||
};
|
||||
|
||||
export enum GuildRateLimiterKey {
|
||||
legacyImport = 'legacyImport',
|
||||
cacheClear = 'cacheClear',
|
||||
}
|
||||
|
||||
export const useGuildRateLimiter = (
|
||||
guildID: string,
|
||||
key: GuildRateLimiterKey,
|
||||
timeoutSeconds: number
|
||||
) => useRateLimiter(Guilds, `guilds/${guildID}/rate-limit/${key}`, timeoutSeconds);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue