fix: dual-mount blogroll at /blogrollapi and /rssapi

/blogroll static page hardcodes /blogrollapi/api/* calls.
/news static page hardcodes /rssapi/api/* calls.
Both must work simultaneously.

- Revert mountPath to /blogrollapi (restores /blogroll page)
- Patch init() to also register publicRouter at /rssapi via a
  thin Indiekit.addEndpoint() alias (fixes /news page)
- /api/feeds alias retained for /news page (maps to listBlogs)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Sven
2026-03-13 19:09:48 +01:00
parent d411a87161
commit c4299b73b1
2 changed files with 37 additions and 7 deletions

View File

@@ -425,7 +425,7 @@ export default {
checked: false
},
"@rmdes/indiekit-endpoint-blogroll": {
mountPath: "/rssapi",
mountPath: "/blogrollapi",
syncInterval: 3600000,
maxItemsPerBlog: 50,
maxItemAge: 7,

View File

@@ -1,9 +1,16 @@
/**
* Patch: add /api/feeds alias for /api/blogs in the blogroll endpoint.
* Patch: dual-mount blogroll public API at /blogrollapi AND /rssapi,
* and add a /api/feeds alias for /api/blogs.
*
* The /news/ static page fetches /rssapi/api/feeds to populate the feed-source
* filter dropdown. The blogroll endpoint exposes the same data under /api/blogs.
* This patch inserts a /api/feeds route that delegates to the same controller.
* Problem: two static pages call different base paths:
* /blogroll → fetches /blogrollapi/api/blogs, /api/categories, /api/items, /api/status
* /news → fetches /rssapi/api/items, /rssapi/api/feeds, /rssapi/api/status
*
* Solution:
* 1. Keep mountPath "/blogrollapi" (serves the /blogroll page as-is).
* 2. In init(), register a thin second endpoint at "/rssapi" pointing to the
* same publicRouter so the /news page's fetches also resolve.
* 3. Add /api/feeds as an alias of /api/blogs on both routers.
*/
import { access, readFile, writeFile } from "node:fs/promises";
@@ -20,6 +27,29 @@ const patchSpecs = [
// feeds alias for /api/blogs (used by the /news/ static page)
publicRouter.get("/api/feeds", apiController.listBlogs);`,
},
{
name: "blogroll-rssapi-dual-mount",
marker: "rssapi dual-mount alias",
candidates: [
"node_modules/@rmdes/indiekit-endpoint-blogroll/index.js",
"node_modules/@indiekit/indiekit/node_modules/@rmdes/indiekit-endpoint-blogroll/index.js",
],
oldSnippet: ` init(Indiekit) {
Indiekit.addEndpoint(this);`,
newSnippet: ` init(Indiekit) {
Indiekit.addEndpoint(this);
// rssapi dual-mount alias: register the same public routes at /rssapi
// so the /news static page (which hardcodes /rssapi/api/*) also works
// alongside the /blogroll page (which hardcodes /blogrollapi/api/*).
Indiekit.addEndpoint({
name: "Blogroll /rssapi alias",
mountPath: "/rssapi",
get routesPublic() {
return publicRouter;
},
});`,
},
];
async function exists(filePath) {
@@ -68,9 +98,9 @@ for (const spec of patchSpecs) {
if (filesChecked === 0) {
console.log("[postinstall] No blogroll endpoint files found");
} else if (filesPatched === 0) {
console.log("[postinstall] blogroll feeds alias already patched");
console.log("[postinstall] blogroll feeds alias + rssapi dual-mount already patched");
} else {
console.log(
`[postinstall] Patched blogroll feeds alias in ${filesPatched}/${filesChecked} file(s)`,
`[postinstall] Patched blogroll feeds alias + rssapi dual-mount in ${filesPatched}/${filesChecked} file(s)`,
);
}