Commit 7aa455f
feat(global): add public API endpoint for navigation data (#266)
## Summary
- Adds a read-only REST endpoint at `GET
/api/v1/@apostrophecms/global/nav`
- Returns `{ primaryNav, footerLinks, socialMediaLinks }` with resolved
`_page` relationships
- No authentication required — enables the Next.js marketing app to
consume nav data
- Zero new dependencies, zero database changes, zero impact on existing
behavior
## Details
Uses Apostrophe's built-in `apiRoutes` pattern (same as the form
module's `routes`). The handler reads from `req.data.global`, which is
already populated by Apostrophe's global middleware on every request —
no extra DB queries.
**1 file changed, 14 lines added:**
`website/modules/@apostrophecms/global/index.js`
## Test plan
- [x] ESLint passes
- [x] All 196 tests pass (`npm run test`)
- [x] Runtime verified via Docker — endpoint returns clean JSON
- [ ] `curl http://localhost:3000/api/v1/@apostrophecms/global/nav`
returns nav JSON
- [ ] Existing CMS admin pages unaffected
- [ ] No auth token needed for the endpoint
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
Adds a public GET /api/v1/@apostrophecms/global/nav endpoint exposing
navigation data (primaryNav, footerLinks, socialMediaLinks) as JSON.
Implemented via Apostrophe’s apiRoutes, handler reads req.data.global
(defensive guard defaults to {}), returns empty-array fallbacks,
requires no authentication, adds no deps or schema changes, and avoids
extra database queries or runtime changes.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Sasha.Marchuk <Sasha.Marchuk.email@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent ebb62e0 commit 7aa455f
1 file changed
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
136 | 150 | | |
0 commit comments