1
0
Fork 0
mirror of https://gitbruv.vercel.app/api/git/bruv/gitbruv.git synced 2025-12-20 23:24:09 +01:00

rate limit and auth checks

This commit is contained in:
Ahmet Kilinc 2025-12-20 14:06:02 +00:00
parent 125c6fdd6a
commit 91208e44a1
9 changed files with 403 additions and 257 deletions

View file

@ -1,7 +1,16 @@
import { NextRequest, NextResponse } from "next/server";
import { r2Get } from "@/lib/r2";
import { rateLimit } from "@/lib/rate-limit";
export async function GET(request: NextRequest, { params }: { params: Promise<{ filename: string }> }) {
const rateLimitResult = rateLimit(request, "avatar", { limit: 200, windowMs: 60000 });
if (!rateLimitResult.success) {
return new NextResponse("Too Many Requests", {
status: 429,
headers: { "Retry-After": Math.ceil((rateLimitResult.resetAt - Date.now()) / 1000).toString() },
});
}
const { filename } = await params;
const key = `avatars/${filename}`;