mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-17 09:59:10 +00:00
miniflare init
This commit is contained in:
parent
8c07ed3123
commit
688954a2e0
52 changed files with 898 additions and 25 deletions
13
packages/api/old-src/utils/rate-limiting.ts
Normal file
13
packages/api/old-src/utils/rate-limiting.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { WrappedKVNamespace } from '@roleypoly/worker-utils';
|
||||
|
||||
export const useRateLimiter =
|
||||
(kv: WrappedKVNamespace, key: string, timeoutSeconds: number) =>
|
||||
async (): Promise<boolean> => {
|
||||
const value = await kv.get<boolean>(key);
|
||||
if (value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
await kv.put(key, true, timeoutSeconds);
|
||||
return false;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue