miniflare init

This commit is contained in:
41666 2022-01-27 16:54:37 -05:00
parent 8c07ed3123
commit 688954a2e0
52 changed files with 898 additions and 25 deletions

View 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;
};