import { getRateLimiter, getUploadApi } from "@/lib/server/app-services";
import { clientAddress, rateLimitResponse } from "@/lib/server/rate-limit";

export async function POST(request: Request) {
  const limit = await getRateLimiter().consume("upload_create", clientAddress(request), {
    limit: 12,
    windowSeconds: 60 * 60,
  });
  if (!limit.allowed) return rateLimitResponse(limit.retryAfterSeconds);
  return getUploadApi().create(request);
}
