- Заполнены заглушки: user-friendly-messages, health, aria, keyboard - backend: core/auth.py, /api/v1/stats; cached-api → backend-client при USE_MOCK_DATA=false - .env.example, middleware auth (skip при USE_MOCK_DATA), убраны неиспользуемые deps - Страницы: airworthiness, maintenance, defects, modifications; AircraftAddModal, Sidebar - Главная страница: REFLY — Контроль лётной годности (вместо Numerology App) - Линт/скрипты: eslintrc, security, cleanup, logs, api inbox/knowledge Co-authored-by: Cursor <cursoragent@cursor.com>
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
export const dynamic = "force-dynamic";
|
|
import { NextRequest, NextResponse } from 'next/server';
|
|
import { getCachedAircraft } from '@/lib/api/cached-api';
|
|
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
const searchParams = request.nextUrl.searchParams;
|
|
const filters: Record<string, string> = {};
|
|
searchParams.forEach((value, key) => { filters[key] = value; });
|
|
|
|
const page = parseInt(filters.page || '1');
|
|
const limit = parseInt(filters.limit || '50');
|
|
|
|
const allData = await getCachedAircraft(filters);
|
|
const total = allData.length;
|
|
const start = (page - 1) * limit;
|
|
const data = allData.slice(start, start + limit);
|
|
|
|
return NextResponse.json({
|
|
data,
|
|
pagination: { page, limit, total, totalPages: Math.ceil(total / limit) }
|
|
}, {
|
|
status: 200,
|
|
headers: { 'Content-Type': 'application/json', 'Cache-Control': 'public, s-maxage=60' },
|
|
});
|
|
} catch (error) {
|
|
return NextResponse.json({ error: 'Internal server error', data: [], pagination: { page: 1, limit: 50, total: 0, totalPages: 1 } }, { status: 500 });
|
|
}
|
|
}
|