From 92a981e5f44db73fefb68e7c79698ddc014b5594 Mon Sep 17 00:00:00 2001 From: Felipe Forbeck Date: Wed, 2 Oct 2024 09:51:54 -0300 Subject: [PATCH] error if rate limit api not found --- src/handlers/rate-limiter.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/handlers/rate-limiter.js b/src/handlers/rate-limiter.js index 9422c2e..732e1d2 100644 --- a/src/handlers/rate-limiter.js +++ b/src/handlers/rate-limiter.js @@ -93,10 +93,11 @@ async function getAuthorizationTokenFromRequest (request) { * @param {import('@cloudflare/workers-types').RateLimit} rateLimitAPI * @param {import('multiformats/cid').CID} cid * @returns {Promise} + * @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) {