Commit 580f6a3
authored
feat(public): docs content contract (/api/public/docs) + decommission Redoc (#3878)
* feat(public): expose docs guides as a structured content tree
Add a public, unauthenticated docs module serving:
- GET /api/public/docs -> { categories: [{ id, label, order,
guides: [{ slug, title, persona, order, summary }] }] }
- GET /api/public/docs/:slug.md -> raw text/markdown (unknown slug -> 404)
Guides are discovered from the existing config.files.guides glob
(modules/*/doc/guides/*.md) and grouped via the config.docs.guideSections
primitive (prefix-range sections, optional per-section persona; persona
defaults to ['all']). Guides outside every range fall back to their
capitalised module name so none is ever dropped. Rate-limited (limiters.api),
~5min in-process TTL cache.
Ship two neutral sample guides (00-welcome, 01-quickstart) under
modules/home/doc/guides and a neutral docs.guideSections default so the
endpoint returns a working tree out of the box.
* refactor(docs): decommission Redoc UI, keep /api/spec.json
Remove the redoc-express dependency and the /api/docs Redoc UI mount, its
theme + custom-CSS blocks, and the config.docs.redocTheme merge. Rename
initSwagger -> initApiSpec; the OpenAPI JSON spec endpoint (/api/spec.json)
is now the documentation surface and keeps the YAML merge, config-injected
info/servers/x-logo, and the markdown guides merge into info.description.
The config.swagger.enable + non-dev env gate is unchanged (now gates
spec-serving only). Tests: drop the Redoc-UI assertions, strengthen the
spec assertions, and add coverage asserting /api/docs is no longer mounted.
* refactor(audit): drop dead /api/docs skip-prefix after Redoc decom
* fix(public): warn on duplicate guide slugs + Cache-Control on docs endpoints
M1: replace silent last-win Map construction in publicDocs.service compute()
with an explicit loop that logger.warn()s on duplicate slugs.
M2: add comment in load() explaining why no inflight guard is needed
(compute() is fully synchronous — no stampede risk on the event loop).
M3: set Cache-Control: public, max-age=300 on both the tree and raw-markdown
200 responses in publicDocs.controller (matches the 5-min in-process TTL);
add controller unit tests asserting the header is present on 200 and absent
on 404.
L4: document NN-kebab-name.md filename convention in slugFromPath.
L5: add comment in express.docs.unit.tests.js second describe block noting
that every new test must stub loadGuides inline (no module-level mock).
nit: trim docs.guideSections block comment in development.config.js to
one line pointing at the helper JSDoc.
* refactor(public): rename docs files to devkit convention + defensive copies + deterministic ordering
F1: git mv all publicDocs.* files to public.docs.{type}.js (dot-separated, module-prefixed,
routes plural); update every import and reference including test mocks and config comment.
F2/F3: guideFiles() returns [...config.files.guides], guideSections() returns .map(s=>({...s}))
so callers cannot mutate config state.
F4: [...filePaths].sort() before .map() so fallback index for unprefixed guides is
platform-stable (glob order is not guaranteed).
F5: sort tiebreaker a.slug.localeCompare(b.slug) for equal numeric prefixes.
F6: remove try/catch in beforeAll — let bootstrap() throw with its real stack trace.
F7: update stale Redoc/reference-sidebar comments in public.docs.tree.js and
development.config.js (guideSections groups public docs contract only).
* test(public): strengthen /api/docs decom assertion + JSDoc helpers + async @returns1 parent 3937953 commit 580f6a3
22 files changed
Lines changed: 1349 additions & 406 deletions
File tree
- config/defaults
- lib
- helpers
- services
- tests
- modules
- audit
- middlewares
- tests
- core/tests
- home/doc/guides
- public
- controllers
- helpers
- routes
- services
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
21 | 27 | | |
22 | 28 | | |
23 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
| 13 | + | |
| 14 | + | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
| |||
105 | 104 | | |
106 | 105 | | |
107 | 106 | | |
108 | | - | |
| 107 | + | |
109 | 108 | | |
110 | 109 | | |
111 | 110 | | |
112 | | - | |
113 | | - | |
| 111 | + | |
114 | 112 | | |
115 | 113 | | |
116 | 114 | | |
117 | 115 | | |
118 | | - | |
| 116 | + | |
119 | 117 | | |
120 | 118 | | |
121 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 43 | + | |
75 | 44 | | |
76 | 45 | | |
77 | 46 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
82 | 51 | | |
83 | 52 | | |
84 | 53 | | |
| |||
136 | 105 | | |
137 | 106 | | |
138 | 107 | | |
139 | | - | |
140 | | - | |
| 108 | + | |
| 109 | + | |
141 | 110 | | |
142 | 111 | | |
143 | 112 | | |
| |||
156 | 125 | | |
157 | 126 | | |
158 | 127 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | 128 | | |
183 | 129 | | |
184 | 130 | | |
| |||
371 | 317 | | |
372 | 318 | | |
373 | 319 | | |
374 | | - | |
375 | | - | |
| 320 | + | |
| 321 | + | |
376 | 322 | | |
377 | 323 | | |
378 | 324 | | |
| |||
415 | 361 | | |
416 | 362 | | |
417 | 363 | | |
418 | | - | |
| 364 | + | |
419 | 365 | | |
420 | 366 | | |
421 | 367 | | |
| |||
0 commit comments