Make it easier to call the limit fn in endpoints, without requiring any imports, by accepting rate and size parameters directly (which are normally used for the Refill constructor). The api object on locals could also expose the SECOND, MINUTE, etc... constants
before
import { MINUTE, Refill } from 'svelte-api-keys'
const rate = new Refill(30 / MINUTE, 10)
export async function GET({ locals }) {
await locals.api.has('read').limit(rate)
// process request
}
after
export async function GET({ locals }) {
await locals.api.has('read').limit(30 / locals.api.MINUTE, 10)
// process request
}
Make it easier to call the limit fn in endpoints, without requiring any imports, by accepting
rate
andsize
parameters directly (which are normally used for theRefill
constructor). Theapi
object on locals could also expose theSECOND
,MINUTE
, etc... constantsbefore
after