-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
captcha
dependency to lobbies module
- Loading branch information
Showing
8 changed files
with
151 additions
and
9 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
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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Config, CaptchaProvider, RateLimitByEndpointId, RateLimitConfig } from "../config.ts"; | ||
|
||
export function getCaptchaProvider(config: Config): CaptchaProvider | null { | ||
if (!config.captcha || !config.captcha.provider) return null; | ||
|
||
return config.captcha.provider; | ||
} | ||
|
||
type KnownEndpoint = keyof RateLimitByEndpointId; | ||
|
||
const endpointRateLimits: RateLimitByEndpointId = { | ||
list: { | ||
period: 20, | ||
requests: 5 | ||
}, | ||
create: { | ||
period: 15, | ||
requests: 5 | ||
}, | ||
join: { | ||
period: 15, | ||
requests: 8 | ||
}, | ||
find_or_create: { | ||
period: 15, | ||
requests: 8 | ||
}, | ||
find: { | ||
period: 15, | ||
requests: 10 | ||
} | ||
} | ||
|
||
export function getRateLimitConfigByEndpoint( | ||
config: Config, | ||
endpoint: KnownEndpoint | ||
): Readonly<RateLimitConfig> { | ||
return config.captcha?.endpointRateLimits?.[endpoint] ?? endpointRateLimits[endpoint]; | ||
} |