Skip to content

Commit

Permalink
chore!: Remove count property on ArcjetRateLimitReason
Browse files Browse the repository at this point in the history
  • Loading branch information
blaine-arcjet committed Feb 5, 2024
1 parent 6753117 commit 4a3b95b
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 16 deletions.
1 change: 0 additions & 1 deletion arcjet/test/index.node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,6 @@ describe("ArcjetDecision", () => {
test("`isRateLimit()` returns true when reason is RATE_LIMIT", () => {
const reason = new ArcjetRateLimitReason({
max: 0,
count: 0,
remaining: 0,
});
expect(reason.isRateLimit()).toEqual(true);
Expand Down
1 change: 0 additions & 1 deletion examples/nextjs-14-openai/app/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export async function POST(req: Request) {
console.log("Arcjet decision", decision.conclusion);

if (decision.reason.isRateLimit()) {
console.log("Request count", decision.reason.count);
console.log("Requests remaining", decision.reason.remaining);
}

Expand Down
2 changes: 0 additions & 2 deletions protocol/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ export function ArcjetReasonFromProtocol(proto?: Reason) {
const reason = proto.reason.value;
return new ArcjetRateLimitReason({
max: reason.max,
count: reason.count,
remaining: reason.remaining,
resetTime: reason.resetTime?.toDate(),
});
Expand Down Expand Up @@ -289,7 +288,6 @@ export function ArcjetReasonToProtocol(reason: ArcjetReason): Reason {
case: "rateLimit",
value: new RateLimitReason({
max: reason.max,
count: reason.count,
remaining: reason.remaining,
resetTime: reason.resetTime
? Timestamp.fromDate(reason.resetTime)
Expand Down
9 changes: 1 addition & 8 deletions protocol/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,13 @@ export class ArcjetRateLimitReason extends ArcjetReason {
type: "RATE_LIMIT" = "RATE_LIMIT";

max: number;
count: number;
remaining: number;
resetTime?: Date;

constructor(init: {
max: number;
count: number;
remaining: number;
resetTime?: Date;
}) {
constructor(init: { max: number; remaining: number; resetTime?: Date }) {
super();

this.max = init.max;
this.count = init.count;
this.remaining = init.remaining;
this.resetTime = init.resetTime;
}
Expand Down
4 changes: 0 additions & 4 deletions protocol/test/convert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ describe("convert", () => {
ArcjetReasonToProtocol(
new ArcjetRateLimitReason({
max: 1,
count: 2,
remaining: -1,
}),
),
Expand All @@ -364,7 +363,6 @@ describe("convert", () => {
case: "rateLimit",
value: {
max: 1,
count: 2,
remaining: -1,
},
},
Expand All @@ -375,7 +373,6 @@ describe("convert", () => {
ArcjetReasonToProtocol(
new ArcjetRateLimitReason({
max: 1,
count: 2,
remaining: -1,
resetTime,
}),
Expand All @@ -386,7 +383,6 @@ describe("convert", () => {
case: "rateLimit",
value: {
max: 1,
count: 2,
remaining: -1,
resetTime: Timestamp.fromDate(resetTime),
},
Expand Down

0 comments on commit 4a3b95b

Please sign in to comment.