feat(web): Last.fm client lib + top-artists/albums + mb release-group routes
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { searchReleaseGroup } from "@/lib/musicbrainz";
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const url = new URL(request.url);
|
||||
const artist = url.searchParams.get("artist");
|
||||
const album = url.searchParams.get("album");
|
||||
if (!artist || !artist.trim() || !album || !album.trim()) {
|
||||
return Response.json({ error: "artist and album are required" }, { status: 400 });
|
||||
}
|
||||
|
||||
let match;
|
||||
try {
|
||||
match = await searchReleaseGroup(artist.trim(), album.trim());
|
||||
} catch {
|
||||
return Response.json({ error: "MusicBrainz unavailable" }, { status: 502 });
|
||||
}
|
||||
if (!match) {
|
||||
return Response.json({ error: "no match" }, { status: 404 });
|
||||
}
|
||||
return Response.json(match);
|
||||
}
|
||||
Reference in New Issue
Block a user