feat(search): server-side offset pagination through providers + /search route (#115 backend)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
saopig1andClaude Opus 4.8 committed 2026-07-04 14:36:54 +08:00
1 parent 81b8953d52
commit a1cc0b8574
14 files changed
+322 -34

No files matched your search

+6 -2
View File
@@ -84,7 +84,7 @@ export function createMusicRouter(
router.get("/search", async (req, res) => {
try {
const { q, platform, limit } = req.query;
const { q, platform, limit, offset } = req.query;
if (!q) {
res.status(400).json({ error: "q (query) is required" });
return;
@@ -94,9 +94,13 @@ export function createMusicRouter(
return;
}
const provider = getProvider(platform as string);
// Server-side pagination: offset lets the web load past the first page.
// Clamp to >= 0 so a bad/negative value falls back to the first page.
const parsedOffset = Math.max(0, parseInt(offset as string) || 0);
const result = await provider.search(
q as string,
parseInt(limit as string) || 20
parseInt(limit as string) || 20,
parsedOffset
);
res.json(result);
} catch (err) {