diff --git a/server/routes.guards.json b/server/routes.guards.json index effc46b..e04bc9c 100644 --- a/server/routes.guards.json +++ b/server/routes.guards.json @@ -1947,6 +1947,12 @@ "validate" ] }, + { + "method": "GET", + "path": "/api/v1/public/modules", + "handlers": 1, + "gates": [] + }, { "method": "GET", "path": "/api/v1/public/pages/:id/preview/:token", diff --git a/server/routes.manifest.json b/server/routes.manifest.json index 3e97f78..5ce03ea 100644 --- a/server/routes.manifest.json +++ b/server/routes.manifest.json @@ -781,6 +781,10 @@ "method": "POST", "path": "/api/v1/public/contact" }, + { + "method": "GET", + "path": "/api/v1/public/modules" + }, { "method": "GET", "path": "/api/v1/public/pages/:id/preview/:token" diff --git a/server/src/router/v1/public/index.js b/server/src/router/v1/public/index.js index 4de3329..0737905 100644 --- a/server/src/router/v1/public/index.js +++ b/server/src/router/v1/public/index.js @@ -22,6 +22,7 @@ const wikiRouter = require('./wiki.router') const pagesRouter = require('./pages.router') const shardRouter = require('./shard.router') const atlasRouter = require('./atlas.router') +const modulesRouter = require('./modules.router') const siteRouter = require('./site.router') const publicRouter = express.Router() @@ -38,6 +39,12 @@ publicRouter.use('/shard', shardRouter) // here depends on the bridge — and site-mode gated per route like the content // routers above, which is the other half of that distinction. publicRouter.use('/atlas', atlasRouter) +// What this backend serves beyond core. A real prefix layer rather than a fifth +// singleton in site.router.js, because the loader's prefix-collision probe reads +// the live tier stack and skips root-mounted layers — this mount is what makes +// /modules unclaimable by a module. Never site-mode gated: a client must be able +// to feature-detect while the site is in maintenance. +publicRouter.use('/modules', modulesRouter) // The four singletons that own no path segment of their own: /settings, /status, // /version and /contact. Mounted at the group root, last — safe only because diff --git a/server/src/router/v1/public/modules.controller.js b/server/src/router/v1/public/modules.controller.js new file mode 100644 index 0000000..a1a2b50 --- /dev/null +++ b/server/src/router/v1/public/modules.controller.js @@ -0,0 +1,60 @@ +// Public · Modules — what this backend is currently serving beyond core. +// +// Phase 2, PR 6 of docs/website/MODULE_SYSTEM.md §2.7. The published shape is +// settled in MODULE_API.md §2.1 (`capabilities` are opaque strings, published +// here, for clients to feature-detect against). +// +// Two decisions are visible in the ten lines below and are the whole of this +// file's design: +// +// • **`started` only.** The public surface answers "what is serving", and +// nothing else. A module that failed to load, or that an operator disabled, +// is simply ABSENT — the same treatment §4.4 already gives its routes and +// its nav, so an anonymous visitor sees a site without that capability +// rather than a site advertising a capability that 503s. `state`, the +// failure stage and the failure reason are core's business and belong to the +// admin Modules screen; none of the three is published here. +// • **No database, and no siteMode gate.** The answer comes from the loader's +// in-memory records, so this endpoint keeps working with the database down — +// the same class as /public/version and /public/status, both of which must +// answer during maintenance so a client can bootstrap and render the +// maintenance page. A client that could not feature-detect while the site +// was in maintenance would render its maintenance page as though no module +// existed. +// +// This endpoint is deliberately NOT how a module's client chunk gets loaded. +// `utils/htmlShell.js` injects a `