Skip to content

Commit

Permalink
error if rate limit api not found
Browse files Browse the repository at this point in the history
  • Loading branch information
fforbeck committed Oct 2, 2024
1 parent e37c45c commit 92a981e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/handlers/rate-limiter.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,11 @@ async function getAuthorizationTokenFromRequest (request) {
* @param {import('@cloudflare/workers-types').RateLimit} rateLimitAPI
* @param {import('multiformats/cid').CID} cid
* @returns {Promise<import('../constants.js').RATE_LIMIT_EXCEEDED>}
* @throws {Error} if no rate limit API is found
*/
async function isRateLimited (rateLimitAPI, cid) {
if (!rateLimitAPI) {
return RATE_LIMIT_EXCEEDED.NO
throw new Error('no rate limit API found')
}
const rateLimitResponse = await rateLimitAPI.limit({ key: cid.toString() })
if (rateLimitResponse.success) {
Expand Down

0 comments on commit 92a981e

Please sign in to comment.