refactor(server): split admin posts, uploads, wiki and pages into capability routers (PR 3) #104
Reference in New Issue
Block a user
No description provided.
Delete Branch "refactor/admin-router-split-3"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What & why
PR 3 of the in-place admin router split — see
docs/website/API_V2_PLAN.md§ Phase 2. Follows #102 (PR 1) and #103 (PR 2). Docs PR: RunicGateway/docs#56.This is the content tier. Four capabilities move out of the residual
admin.routes.jsinto their own router files, each mounted at the prefix it already owned, so no URL, gate or handler changes.posts.router.js/admin/postsuploads.router.js/admin/uploadswiki.router.js/admin/wikipages.router.js/admin/pagesadmin.routes.js(residual)31 + 33 + the 46 already extracted = the 110 inventoried admin routes.
First split PR where no gate moved at all. All four capabilities are editor-tier, so the shared
noindex, isLoggedIn, staffOnlygate inadmin/index.jsis their whole gate. PR 2's rule ("move a gate to router level only where it was already a prefix mount") had nothing to act on here.Three things worth a reviewer's attention
admin/imageUpload.js— the first shared module in the split. The multer config (upload dir, mimetype→extension allowlist, 8 MB cap) was inline inadmin.routes.jsand used by two routes that this PR puts in different files:POST /posts/upload(returns{image_url}) andPOST /uploads(returns{url}). It moved to a shared module rather than being duplicated — duplicating a security allowlist is how the two copies drift. It stays inadmin/deliberately:UPLOAD_DIRis resolved__dirname-relative, so relocating the file would silently repoint the upload directory.POST /uploadskeeps itsAdmin · Postsswagger tag, which now disagrees with its filename. The acceptance criterion here is a byte-identical spec, so retagging is a real OpenAPI diff and doesn't belong in a route-move PR — same call as PR 1 made for the/shard/*tag mismatch.The wiki router has load-bearing intra-file route order.
/categoriesand/tagsare literal paths that must stay ahead of/:slug, orGET /admin/wiki/categoriesgets dispatched as a page whose slug is"categories". None of the three gates can catch this — the manifest sorts its entries, so a reordering is invisible. Verified separately (below).Also noted for next time: the residual 33 is exactly PR 4's list (shard 16, email 6, uo-link 5, settings 2, discord-bot 2, dashboard 1, site-mode 1), so
admin.routes.jsgets deleted by PR 4, and PR 5 touches onlypublic/*,player/*andauth/*.How it was tested
All four freeze gates came back zero-diff, which is this PR's acceptance criterion:
docs/website/api-route-inventory.jsonwas already in sync, so it needed no refresh.The generated artifacts are not in this diff — they regenerate byte-identically, which is the point.
Plus the one check no gate can make, on the wiki ordering hazard — introspecting the built router stack and asserting the last literal layer precedes the first
/:sluglayer:Checklist
AI-assisted contributions (required)
This project requires disclosure of AI tool usage. Please pick one:
Claude Code (Opus 5). I have reviewed and understandevery change, and take responsibility for it. AI-authored commits are
marked with a
Co-Authored-By/Assisted-Bytrailer.License
(GNU GPL v3.0 or later), and I have the right to contribute it.