Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

560 B
Raw Blame
import type { KvStore } from '../../kv-store/kv-store.types';
import type { RateLimitKvStore } from './rate-limit.types';
import * as v from 'valibot';
import { positiveIntegerSchema } from '../../shared/schemas/number.schemas';

const rateLimitKvStoreEntrySchema = v.object({
  hitCount: positiveIntegerSchema,
  resetAtEpochMs: positiveIntegerSchema,
});

export function scopeKvStoreForRateLimit({ kvStore }: { kvStore: KvStore }): RateLimitKvStore {
  return kvStore.defineScope({
    prefix: 'rate-limit',
    schema: rateLimitKvStoreEntrySchema,
  });
}