refactor(server): extract dashboard static plugin (#3154)#3159
Merged
Conversation
Comment on lines
+153
to
+163
| app.get('/manifest.json', async (_req, reply) => { | ||
| const manifestPath = path.join(dashboardRoot, 'manifest.json'); | ||
| try { | ||
| const data = await fs.readFile(manifestPath, 'utf-8'); | ||
| reply.header('Content-Type', 'application/manifest+json'); | ||
| reply.header('Cache-Control', 'public, max-age=3600'); | ||
| return reply.send(data); | ||
| } catch { | ||
| return reply.status(404).send({ error: 'manifest.json not found' }); | ||
| } | ||
| }); |
Phase 1, extraction #3: Dashboard static file serving. Moves 175 lines of dashboard serving code from server.ts to a new Fastify plugin at src/plugins/dashboard-static.ts: - CSP headers, cache control, static file serving - SPA fallback for dashboard routes - Root redirect to /dashboard/ - manifest.json for PWA install - Content-Length defensive header server.ts: 1513 β 1384 lines (-129 lines, -8.5%) No API changes. All dashboard behavior preserved.
Plugin used __dirname which is undefined in ESM modules. Replaced with fileURLToPath(import.meta.url) pattern matching server.ts.
1727deb to
2b7cace
Compare
Contributor
There was a problem hiding this comment.
β Approved β all 9 merge gates passed.
Review: refactor(server): extract dashboard static plugin (#3154)
- Pure extraction: 129 lines moved from server.ts β plugins/dashboard-static.ts with zero logic changes
- CSP headers, cache control, SPA fallback, manifest.json serving β all preserved identically
registerDashboardStatic()returns boolean for dashboard availability (same contract as inline code)- Test updated: CSP test reads from plugin file instead of server.ts
- No new dependencies, no API changes, no security implications
- All 7 required CI checks green (CodeQL external is non-required, likely transient)
- server.ts: 1513 β 1384 lines (-8.5%) β clean decomposition step
Gate 3 (CI green): β
All required checks pass
Gate 5 (unit tests): β
Existing test suite covers functionality
Gate 9 (targets develop): β
Ready to merge.
ποΈ Argus
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.
What
Phase 1 of server.ts decomposition (#3154). Extracts dashboard static file serving into a standalone Fastify plugin.
Changes
src/plugins/dashboard-static.ts(175 lines) β CSP headers, cache control, static file serving, SPA fallback, root redirect, manifest.jsonsrc/server.tsβ 1513 β 1384 lines (-129 lines, -8.5%)src/__tests__/dashboard-static.test.tsβ CSP test updated to check plugin file instead of server.tsNo API changes
All dashboard behavior preserved. The plugin is a drop-in replacement for the inline code in main().
Verification