Files
podzahr/app/api/albums/[id]/route.ts
T
2025-12-27 23:37:46 +03:30

28 lines
640 B
TypeScript

import { NextRequest, NextResponse } from 'next/server';
import { albumDb } from '@/lib/db';
export async function GET(
request: NextRequest,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params;
const album = albumDb.getById(id);
if (!album) {
return NextResponse.json(
{ error: 'Album not found' },
{ status: 404 }
);
}
return NextResponse.json(album, { status: 200 });
} catch (error) {
console.error('Error fetching album:', error);
return NextResponse.json(
{ error: 'Failed to fetch album' },
{ status: 500 }
);
}
}