refactor: update API rate limit to 600 req/min and improve queue status polling logic
This commit is contained in:
@@ -31,7 +31,7 @@ const handleBetterAuth: Handle = async ({ event, resolve }) => {
|
|||||||
// 200 req/min per IP — high enough for legit use, stops bots/scrapers.
|
// 200 req/min per IP — high enough for legit use, stops bots/scrapers.
|
||||||
if (event.url.pathname.startsWith('/api/')) {
|
if (event.url.pathname.startsWith('/api/')) {
|
||||||
const ip = event.getClientAddress();
|
const ip = event.getClientAddress();
|
||||||
const { ok, retryAfter } = checkRateLimit(`api:${ip}`, 200, 60_000);
|
const { ok, retryAfter } = checkRateLimit(`api:${ip}`, 600, 60_000);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return new Response('Too Many Requests', {
|
return new Response('Too Many Requests', {
|
||||||
status: 429,
|
status: 429,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { invalidateAll } from '$app/navigation';
|
import { invalidateAll } from '$app/navigation';
|
||||||
import { page } from '$app/state';
|
import { page } from '$app/state';
|
||||||
import { untrack } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
let { data } = $props();
|
let { data } = $props();
|
||||||
|
|
||||||
@@ -67,18 +67,13 @@
|
|||||||
queueLoading = false;
|
queueLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Poll queue status while on dashboard.
|
// Poll queue status with a plain setInterval — no reactive dependencies,
|
||||||
// Rate is read via untrack so queueStatus changes don't re-trigger the effect
|
// so Svelte can never re-trigger it and cause a request flood.
|
||||||
// (which would cause an infinite fetch loop + rate limit exhaustion).
|
onMount(() => {
|
||||||
$effect(() => {
|
if (!data.user) return;
|
||||||
if (data.user) {
|
|
||||||
fetchQueueStatus();
|
fetchQueueStatus();
|
||||||
const interval = setInterval(
|
const id = setInterval(fetchQueueStatus, 4000);
|
||||||
fetchQueueStatus,
|
return () => clearInterval(id);
|
||||||
untrack(() => (queueStatus?.inQueue ? 2000 : 5000))
|
|
||||||
);
|
|
||||||
return () => clearInterval(interval);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function timeAgo(date: string | Date) {
|
function timeAgo(date: string | Date) {
|
||||||
@@ -96,9 +91,9 @@
|
|||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>Vash Esports</title>
|
<title>Vash Esports</title>
|
||||||
<meta name="description" content="Run osu! tournaments with automated lobbies, live scoring, mappools, and team management. Built for serious competition." />
|
<meta name="description" content="very cool and awesome automated osu! matchmaking platform" />
|
||||||
<meta property="og:title" content="Vash Esports" />
|
<meta property="og:title" content="Vash Esports" />
|
||||||
<meta property="og:description" content="Run osu! tournaments with automated lobbies, live scoring, mappools, and team management." />
|
<meta property="og:description" content="very cool and awesome automated osu! matchmaking platform" />
|
||||||
<meta property="og:type" content="website" />
|
<meta property="og:type" content="website" />
|
||||||
<meta property="og:url" content={page.url.href} />
|
<meta property="og:url" content={page.url.href} />
|
||||||
<meta property="og:image" content="/og-image.png" />
|
<meta property="og:image" content="/og-image.png" />
|
||||||
|
|||||||
Reference in New Issue
Block a user