feat: update APKs API to include environment metadata
- Add parseApkFilename() integration to extract environment and commit info - Return environment field (dev/sandbox/product/other) in API response - Return commit field (short commit ID) in API response - Add comprehensive test coverage for the new metadata Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// app/api/apks/route.ts
|
||||
import { NextResponse } from 'next/server';
|
||||
import { getApks } from '@/lib/fs-utils';
|
||||
import { parseApkFilename } from '@/lib/apk-parser';
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
@@ -17,12 +18,17 @@ export async function GET(request: Request) {
|
||||
|
||||
try {
|
||||
const apks = await getApks(project, version, commitId);
|
||||
const apksWithUrls = apks.map(apk => ({
|
||||
...apk,
|
||||
modifiedAt: apk.modifiedAt.toISOString(),
|
||||
downloadUrl: `/api/download?project=${encodeURIComponent(project)}&version=${encodeURIComponent(version)}&filename=${encodeURIComponent(apk.name)}`,
|
||||
}));
|
||||
return NextResponse.json(apksWithUrls);
|
||||
const apksWithMetadata = apks.map(apk => {
|
||||
const parsed = parseApkFilename(apk.name);
|
||||
return {
|
||||
...apk,
|
||||
environment: parsed.environment,
|
||||
commit: parsed.commit,
|
||||
modifiedAt: apk.modifiedAt.toISOString(),
|
||||
downloadUrl: `/api/download?project=${encodeURIComponent(project)}&version=${encodeURIComponent(version)}&filename=${encodeURIComponent(apk.name)}`,
|
||||
};
|
||||
});
|
||||
return NextResponse.json(apksWithMetadata);
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to fetch APK files' },
|
||||
|
||||
Reference in New Issue
Block a user