klg-asutk-app/app/api/parquet/download/route.ts
Yuriy 0150aba4f5 Consolidation: KLG ASUTK + PAPA integration
- Unify API: lib/api.ts uses /api/v1, inbox uses /api/inbox (rewrites)
- Remove localhost refs: openapi, inbox page
- Add rewrites: /api/inbox|tmc -> inbox-server, /api/v1 -> FastAPI
- Add stub routes: knowledge/insights, recommendations, search, log-error
- Transfer from PAPA: prompts (inspection, tmc), scripts, supabase, data/tmc-requests
- Fix inbox-server: ORDER BY created_at, package.json
- Remove redundant app/api/inbox/files route (rewrites handle it)
- knowledge/ in gitignore (large PDFs)

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-08 17:18:31 +03:00

42 lines
1.2 KiB
TypeScript

export const dynamic = "force-dynamic";
import { NextRequest, NextResponse } from 'next/server';
import { getSignedUrlForFile } from '@/lib/storage/s3-client';
import { rateLimit, getRateLimitIdentifier } from '@/lib/rate-limit';
import { handleError } from '@/lib/error-handler';
export async function GET(request: NextRequest) {
try {
const rateLimitResult = rateLimit(getRateLimitIdentifier(request));
if (!rateLimitResult.allowed) {
return NextResponse.json(
{ error: 'Слишком много запросов' },
{ status: 429 }
);
}
const { searchParams } = new URL(request.url);
const key = searchParams.get('key');
const expiresIn = parseInt(searchParams.get('expiresIn') || '3600');
if (!key) {
return NextResponse.json(
{ error: 'Параметр key обязателен' },
{ status: 400 }
);
}
// Генерируем подписанный URL
const signedUrl = await getSignedUrlForFile(key, expiresIn);
return NextResponse.json({
url: signedUrl,
expiresIn,
});
} catch (error: any) {
return handleError(error, {
path: '/api/parquet/download',
method: 'GET',
});
}
}