Skip to content

Commit 1a3fbb6

Browse files
committed
Added reason to test page
1 parent d6a3dbf commit 1a3fbb6

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/routes/+page.server.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { PageServerLoad } from './$types';
44

55
const rates = {
66
IP: [3, 'm'] satisfies Rate,
7-
IPUA: [1, '15s'] satisfies Rate
7+
IPUA: [1, '5s'] satisfies Rate
88
};
99

1010
const limiter = new RetryAfterRateLimiter({ rates });
@@ -20,7 +20,10 @@ export const actions = {
2020
event.setHeaders({
2121
'Retry-After': status.retryAfter.toString()
2222
});
23-
return fail(429, { retryAfter: status.retryAfter });
23+
return fail(429, {
24+
reason: status.reason,
25+
retryAfter: status.retryAfter
26+
});
2427
}
2528
return { retryAfter: 0 };
2629
}

src/routes/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
);
1313
const statusMessage = $derived(
1414
isLimited && currentForm?.retryAfter // Ensure currentForm and retryAfter are defined
15-
? `You are rate limited, retry in ${currentForm.retryAfter} seconds.`
15+
? `You are rate limited due to ${currentForm.reason}, retry in ${currentForm.retryAfter} seconds.`
1616
: 'OK'
1717
);
1818

0 commit comments

Comments
 (0)