website refactor

This commit is contained in:
2026-01-14 02:02:24 +01:00
parent 8d7c709e0c
commit 4522d41aef
291 changed files with 12763 additions and 9309 deletions

View File

@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from 'next/server';
import { proxyMediaRequest, getMediaContentType, getMediaCacheControl } from '@/lib/adapters/MediaProxyAdapter';
export async function GET(
request: NextRequest,
@@ -6,32 +7,16 @@ export async function GET(
) {
const { driverId } = params;
// In test environment, proxy to the mock API
const apiBaseUrl = process.env.API_BASE_URL || 'http://localhost:3000';
const result = await proxyMediaRequest(`/media/avatar/${driverId}`);
try {
const response = await fetch(`${apiBaseUrl}/media/avatar/${driverId}`, {
method: 'GET',
headers: {
'Content-Type': 'image/png',
},
});
if (!response.ok) {
// Return a fallback image or 404
return new NextResponse(null, { status: 404 });
}
const buffer = await response.arrayBuffer();
return new NextResponse(buffer, {
headers: {
'Content-Type': 'image/png',
'Cache-Control': 'public, max-age=3600',
},
});
} catch (error) {
console.error('Error fetching avatar:', error);
return new NextResponse(null, { status: 500 });
if (result.isErr()) {
return new NextResponse(null, { status: 404 });
}
return new NextResponse(result.unwrap(), {
headers: {
'Content-Type': getMediaContentType('/media/avatar'),
'Cache-Control': getMediaCacheControl(),
},
});
}