Skip to content

Commit

Permalink
fix: rename resolveResponses as resolveLimitPayload
Browse files Browse the repository at this point in the history
  • Loading branch information
CahidArda committed Jun 13, 2024
1 parent f1615a0 commit 290dd68
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/deny-list/deny-list.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, test, describe, afterAll, beforeAll } from "bun:test";
import { Redis } from "@upstash/redis";
import { Ratelimit } from "../index";
import { checkDenyListCache, defaultDeniedResponse, resolveResponses } from "./deny-list";
import { checkDenyListCache, defaultDeniedResponse, resolveLimitPayload } from "./deny-list";
import { DenyListResponse, RatelimitResponseType } from "../types";


Expand Down Expand Up @@ -66,7 +66,7 @@ describe("should resolve ratelimit and deny list response", async () => {
invalidIpDenyList: true
};

const response = resolveResponses(spyRedis as Redis, prefix, [initialResponse, denyListResponse], 8);
const response = resolveLimitPayload(spyRedis as Redis, prefix, [initialResponse, denyListResponse], 8);
await response.pending;

expect(response).toEqual(expectedResponse);
Expand All @@ -88,7 +88,7 @@ describe("should resolve ratelimit and deny list response", async () => {
invalidIpDenyList: false
};

const response = resolveResponses(spyRedis as Redis, prefix, [initialResponse, denyListResponse], 8);
const response = resolveLimitPayload(spyRedis as Redis, prefix, [initialResponse, denyListResponse], 8);
await response.pending;

expect(response).toEqual(expectedResponse);
Expand Down
2 changes: 1 addition & 1 deletion src/deny-list/deny-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const checkDenyList = async (
* @param denyListResponse
* @returns
*/
export const resolveResponses = (
export const resolveLimitPayload = (
redis: Redis,
prefix: string,
[ratelimitResponse, denyListResponse]: LimitPayload,
Expand Down
4 changes: 2 additions & 2 deletions src/ratelimit.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Analytics } from "./analytics";
import { Cache } from "./cache";
import type { Algorithm, Context, LimitOptions, LimitPayload, RatelimitResponse, Redis } from "./types";
import { checkDenyList, checkDenyListCache, defaultDeniedResponse, resolveResponses } from "./deny-list/index";
import { checkDenyList, checkDenyListCache, defaultDeniedResponse, resolveLimitPayload } from "./deny-list/index";

export class TimeoutError extends Error {
constructor() {
Expand Down Expand Up @@ -295,7 +295,7 @@ export abstract class Ratelimit<TContext extends Context> {
]);
}

return resolveResponses(this.primaryRedis, this.prefix, result, this.denyListThreshold)
return resolveLimitPayload(this.primaryRedis, this.prefix, result, this.denyListThreshold)
};

/**
Expand Down

0 comments on commit 290dd68

Please sign in to comment.