Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
document the opt-in pagination contract on album/artist/author lists and guard the bare-array default
[._.]/ Adam Eivy28d6f18031f2
diff --git a/server/routes/albums.js b/server/routes/albums.jsindex f208e55e0a..fe25fa8816 100644--- a/server/routes/albums.js+++ b/server/routes/albums.js@@ -1,7 +1,8 @@/*** Music album routes.*- * GET /api/albums → Album[] (live, sorted by title)+ * GET /api/albums → Album[] (live, sorted by title; `?limit`/`?offset`+ * switches to the bounded envelope)* POST /api/albums → Album* GET /api/albums/:id → Album* PATCH /api/albums/:id → Album@@ -104,6 +105,9 @@ async function reconcileAlbumMembership(album) {}));}+// Backward-compatible by default: returns the full albums array. When a client+// passes `limit`/`offset`, the response becomes the bounded+// `{ items, total, limit, offset }` envelope every paginated PortOS list shares.router.get('/', asyncHandler(async (req, res) => {const list = await albums.listAlbums();if (!isPaginationRequested(req.query)) return res.json(list);diff --git a/server/routes/albums.test.js b/server/routes/albums.test.jsindex 618b50f26e..08423d23f7 100644--- a/server/routes/albums.test.js+++ b/server/routes/albums.test.js@@ -49,6 +49,19 @@ describe('albums routes', () => {expect(r.body).toEqual([{ id: 'album-1', title: 'Debut' }]);});+ // Regression guard: every client caller (AlbumsManager, TracksManager) calls+ // listAlbums() with no query params. If this ever returns an envelope instead+ // of a bare array, those lists silently render empty.+ it('GET / without pagination params returns the unbounded bare array', async () => {+ albums.listAlbums.mockResolvedValueOnce(+ Array.from({ length: 120 }, (_, i) => ({ id: `album-${i}`, title: `T${i}` }))+ );+ const r = await request(app).get('/api/albums');+ expect(r.status).toBe(200);+ expect(Array.isArray(r.body)).toBe(true);+ expect(r.body).toHaveLength(120);+ });+it('GET / returns a bounded envelope when pagination is requested', async () => {albums.listAlbums.mockResolvedValueOnce(Array.from({ length: 5 }, (_, i) => ({ id: `album-${i}`, title: `T${i}` }))diff --git a/server/routes/artists.js b/server/routes/artists.jsindex a8f74d4406..c0cefe6b7e 100644--- a/server/routes/artists.js+++ b/server/routes/artists.js@@ -1,7 +1,8 @@/*** Music artist routes.*- * GET /api/artists → Artist[] (live, sorted by name)+ * GET /api/artists → Artist[] (live, sorted by name; `?limit`/`?offset`+ * switches to the bounded envelope)* POST /api/artists → Artist* GET /api/artists/:id → Artist* PATCH /api/artists/:id → Artist@@ -48,6 +49,9 @@ const patchSchema = z.object({portraitImageUrl: portraitImageUrlField.optional(),}).refine((p) => Object.keys(p).length > 0, { message: 'patch must include at least one field' });+// Backward-compatible by default: returns the full artists array. When a client+// passes `limit`/`offset`, the response becomes the bounded+// `{ items, total, limit, offset }` envelope every paginated PortOS list shares.router.get('/', asyncHandler(async (req, res) => {const list = await artists.listArtists();if (!isPaginationRequested(req.query)) return res.json(list);diff --git a/server/routes/artists.test.js b/server/routes/artists.test.jsindex 82b3d19289..ed37e4a98f 100644--- a/server/routes/artists.test.js+++ b/server/routes/artists.test.js@@ -43,6 +43,19 @@ describe('artists routes', () => {expect(r.body).toEqual([{ id: 'artist-1', name: 'Nova' }]);});+ // Regression guard: every client caller (ArtistsManager, ArtistPicker) calls+ // listArtists() with no query params. If this ever returns an envelope instead+ // of a bare array, those lists silently render empty.+ it('GET / without pagination params returns the unbounded bare array', async () => {+ artists.listArtists.mockResolvedValueOnce(+ Array.from({ length: 120 }, (_, i) => ({ id: `artist-${i}`, name: `N${i}` }))+ );+ const r = await request(app).get('/api/artists');+ expect(r.status).toBe(200);+ expect(Array.isArray(r.body)).toBe(true);+ expect(r.body).toHaveLength(120);+ });+it('GET / returns a bounded envelope when pagination is requested', async () => {artists.listArtists.mockResolvedValueOnce(Array.from({ length: 5 }, (_, i) => ({ id: `artist-${i}`, name: `N${i}` }))diff --git a/server/routes/authors.js b/server/routes/authors.jsindex a52e681133..929f02335b 100644--- a/server/routes/authors.js+++ b/server/routes/authors.js@@ -1,7 +1,8 @@/*** Author persona routes.*- * GET /api/authors → Author[] (live, sorted by name)+ * GET /api/authors → Author[] (live, sorted by name; `?limit`/`?offset`+ * switches to the bounded envelope)* POST /api/authors → Author* GET /api/authors/:id → Author* PATCH /api/authors/:id → Author@@ -41,6 +42,9 @@ const patchSchema = z.object({headshotImageUrl: headshotImageUrlField.optional(),}).refine((p) => Object.keys(p).length > 0, { message: 'patch must include at least one field' });+// Backward-compatible by default: returns the full authors array. When a client+// passes `limit`/`offset`, the response becomes the bounded+// `{ items, total, limit, offset }` envelope every paginated PortOS list shares.router.get('/', asyncHandler(async (req, res) => {const list = await authors.listAuthors();if (!isPaginationRequested(req.query)) return res.json(list);diff --git a/server/routes/authors.test.js b/server/routes/authors.test.jsindex c1b10a705e..4066ebe1d4 100644--- a/server/routes/authors.test.js+++ b/server/routes/authors.test.js@@ -42,6 +42,19 @@ describe('authors routes', () => {expect(r.body).toEqual([{ id: 'auth-1', name: 'Jane' }]);});+ // Regression guard: every client caller (Authors page, AuthorPicker) calls+ // listAuthors() with no query params. If this ever returns an envelope instead+ // of a bare array, those lists silently render empty.+ it('GET / without pagination params returns the unbounded bare array', async () => {+ authors.listAuthors.mockResolvedValueOnce(+ Array.from({ length: 120 }, (_, i) => ({ id: `auth-${i}`, name: `A${i}` }))+ );+ const r = await request(app).get('/api/authors');+ expect(r.status).toBe(200);+ expect(Array.isArray(r.body)).toBe(true);+ expect(r.body).toHaveLength(120);+ });+it('GET / returns a bounded envelope when pagination is requested', async () => {authors.listAuthors.mockResolvedValueOnce(Array.from({ length: 5 }, (_, i) => ({ id: `auth-${i}`, name: `A${i}` }))