feat: add /api/apks endpoint

This commit is contained in:
2026-03-04 01:58:52 +08:00
parent c032c7fd5d
commit 0d1ba31175

32
app/api/apks/route.ts Normal file
View File

@@ -0,0 +1,32 @@
// app/api/apks/route.ts
import { NextResponse } from 'next/server';
import { getApks, formatDateTime } from '@/lib/fs-utils';
export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
const project = searchParams.get('project');
const version = searchParams.get('version');
const commitId = searchParams.get('commit') || undefined;
if (!project || !version) {
return NextResponse.json(
{ error: 'Project and version parameters are required' },
{ status: 400 }
);
}
try {
const apks = await getApks(project, version, commitId);
const apksWithUrls = apks.map(apk => ({
...apk,
modifiedAt: apk.modifiedAt.toISOString(),
downloadUrl: `/api/download?project=${project}&version=${version}&filename=${apk.name}`,
}));
return NextResponse.json(apksWithUrls);
} catch (error) {
return NextResponse.json(
{ error: 'Failed to fetch APK files' },
{ status: 500 }
);
}
}