refactor(subsonic): split routes/subsonic.ts into endpoint modules with a query layer (#243) - #247
Merged
Merged
Conversation
…ilders.ts (refs #243) Phase 1 of 4: move buildSong/buildAlbum/annotateStarred/annotatePlays, contentTypeForFormat, audioSourceFields, and the share-ID pickers plus their row types (TrackRow, ReleaseGroupRow) out of the subsonic route monolith. Pure move — no logic, signature, or behavior changes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011Q3riZ78G26ohMgPDh8F7u
…y (refs #243) Phase 2 of 4: 26 prepared statements relocate from routes/subsonic.ts into hub/src/db/queries/subsonic-queries.ts, all prepared eagerly at plugin init (extends the #130 hoisting convention to every static query). Dynamic-SQL queries (getAlbumList2 assembly) stay inline by design. SQL moved byte-for-byte; explicit SubsonicQueries interface so statement-name typos fail typecheck. New init-time smoke test catches SQL/schema drift at boot instead of first request. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011Q3riZ78G26ohMgPDh8F7u
… (refs #243) Phase 3 of 4: routes/subsonic.ts (1,250 lines remaining) deleted; handlers move verbatim into routes/subsonic/{index,browsing,search, playlists,annotations,stream}.ts, each registering through a shared SubsonicRouteContext (app, queries, route/publicRoute/binaryRoute). Registration set, preHandlers, and the castToken path-gating are unchanged; getAlbumList2's dynamic SQL stays inline in browsing.ts. Only import-path change outside the new directory is server.ts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011Q3riZ78G26ohMgPDh8F7u
…efs #243) Phase 4 of 4: opensubsonic.md, opensubsonic-extensions-survey.md, hub-internals.md, authentication.md, and pitfalls.md now point at the endpoint-family modules (builders.ts, stream.ts, index.ts) instead of the deleted routes/subsonic.ts monolith. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011Q3riZ78G26ohMgPDh8F7u
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #243.
Pure refactor, zero behavior change: the 1,819-line
hub/src/routes/subsonic.tsmonolith is now endpoint-family modules with a prepared-statement query layer. Four commits, one per phase:buildSong,buildAlbum,annotateStarred,annotatePlays,contentTypeForFormat,audioSourceFields, share-ID pickers + row types →routes/subsonic/{builders,types}.tscreateSubsonicQueries()inhub/src/db/queries/subsonic-queries.ts, all prepared eagerly at plugin init (extends the #130 hoisting convention). ExplicitSubsonicQueriesinterface so statement-name typos fail typecheck. New init-time smoke test catches SQL/schema drift at boot.index.ts(99),browsing.ts(573),search.ts(84),playlists.ts(34),annotations.ts(210),stream.ts(358), composed via a sharedSubsonicRouteContext. Only external import change isserver.ts.Deliberately unchanged
castTokenpath-gating (requireSubsonicAuthBinary) — no auth files touched.getAlbumList2's dynamically-assembled SQL stays inline inbrowsing.ts(it can't be eagerly prepared).BEST_SOURCE_SUBQUERYre-exported byte-for-byte even though it appears to be dead code (flagged on the issue for a follow-up — deleting dead code is out of scope for a pure refactor).Verification
pnpm verifygreen: 55 hub + 16 frontend test files (676+ tests), typecheck clean,lint:boundaryzero output.pnpm lintzero findings in bothhub/andfrontend/(the root-level combined runner OOMs locally — pre-existing env quirk, unrelated; CI lints per-package).subsonic-routes,subsonic,stream,star-routes,play-events,subsonic-internal-auth,cast-token-stream.integration) pass unmodified.Notes
browsing.tsat 573 lines (23 over the ~550 allowance noted in the issue, becausegetAlbumList2's dynamic SQL stays inline); nodb.prepareinside request handlers in the new modules.index.ts) has no effect on Fastify routing.🤖 Generated with Claude Code
https://claude.ai/code/session_011Q3riZ78G26ohMgPDh8F7u