From fed565795754f8db75a399a3c725e56e89fcd522 Mon Sep 17 00:00:00 2001 From: svemagie <869694+svemagie@users.noreply.github.com> Date: Mon, 9 Mar 2026 14:10:59 +0100 Subject: [PATCH] Add webmentions proxy endpoint integration --- .env.example | 7 +++++++ README.md | 10 ++++++++++ indiekit.config.mjs | 16 ++++++++++++++++ package-lock.json | 16 ++++++++++++++++ package.json | 1 + 5 files changed, 50 insertions(+) diff --git a/.env.example b/.env.example index d3029eef..d07d5840 100644 --- a/.env.example +++ b/.env.example @@ -20,6 +20,13 @@ WEBMENTION_SENDER_TIMEOUT=10000 # User-Agent used for target endpoint discovery and sends WEBMENTION_SENDER_USER_AGENT= +# Optional webmentions proxy endpoint settings +# Default mount path in indiekit.config.mjs is /webmentions-api +WEBMENTIONS_PROXY_MOUNT_PATH=/webmentions-api + +# Cache TTL in seconds for proxied webmention.io API responses +WEBMENTIONS_PROXY_CACHE_TTL=60 + # Syndication endpoint mount path # Default in indiekit.config.mjs is /syndicate SYNDICATE_MOUNT_PATH=/syndicate diff --git a/README.md b/README.md index 9deb38a2..1a4ff85b 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ - Posts management: `/posts` - Files: `/files` - Webmentions moderation + API: `/webmentions` +- Webmentions proxy API: `/webmentions-api` - Webmention sender + API: `/webmention-sender` - Homepage builder UI + API: `/homepage` - Conversations + API: `/conversations` @@ -102,6 +103,15 @@ - `WEBMENTION_SENDER_USER_AGENT` (default `${SITE_NAME} Webmention Sender`) - `POST /webmention-sender` requires authentication (`update` scope) and sends pending webmentions for unpublished targets. +## Webmentions proxy + +- Webmentions proxy endpoint is enabled via `@rmdes/indiekit-endpoint-webmentions-proxy` and mounted at `/webmentions-api` by default. +- Optional environment variables: +- `WEBMENTIONS_PROXY_MOUNT_PATH` (default `/webmentions-api`) +- `WEBMENTIONS_PROXY_CACHE_TTL` (default `60`, cache TTL in seconds) +- Uses existing `WEBMENTION_IO_TOKEN` and `WEBMENTION_IO_DOMAIN` configuration for upstream webmention.io requests. +- Public JSON API route: `GET /webmentions-api/api/mentions` (supports `page`, `per-page`, `target`, `wm-property` query parameters). + ## ActivityPub - ActivityPub federation is enabled via `@rmdes/indiekit-endpoint-activitypub`. diff --git a/indiekit.config.mjs b/indiekit.config.mjs index 83f47492..f2ecb1a3 100644 --- a/indiekit.config.mjs +++ b/indiekit.config.mjs @@ -78,6 +78,15 @@ const webmentionSenderTimeout = Number.isFinite(webmentionSenderTimeoutRaw) : 10000; const webmentionSenderUserAgent = process.env.WEBMENTION_SENDER_USER_AGENT || `${siteName} Webmention Sender`; +const webmentionsProxyMountPath = + process.env.WEBMENTIONS_PROXY_MOUNT_PATH || "/webmentions-api"; +const webmentionsProxyCacheTtlRaw = Number.parseInt( + process.env.WEBMENTIONS_PROXY_CACHE_TTL || "60", + 10, +); +const webmentionsProxyCacheTtl = Number.isFinite(webmentionsProxyCacheTtlRaw) + ? webmentionsProxyCacheTtlRaw + : 60; const authorName = process.env.AUTHOR_NAME || ""; const authorBio = process.env.AUTHOR_BIO || ""; const authorAvatar = (() => { @@ -208,6 +217,7 @@ export default { "@rmdes/indiekit-preset-eleventy", "@rmdes/indiekit-endpoint-github", "@rmdes/indiekit-endpoint-webmention-io", + "@rmdes/indiekit-endpoint-webmentions-proxy", "@rmdes/indiekit-endpoint-webmention-sender", "@rmdes/indiekit-endpoint-homepage", "@rmdes/indiekit-endpoint-conversations", @@ -248,6 +258,12 @@ export default { token: process.env.WEBMENTION_IO_TOKEN, domain: webmentionDomain, }, + "@rmdes/indiekit-endpoint-webmentions-proxy": { + mountPath: webmentionsProxyMountPath, + token: process.env.WEBMENTION_IO_TOKEN, + domain: webmentionDomain, + cacheTtl: webmentionsProxyCacheTtl, + }, "@rmdes/indiekit-endpoint-webmention-sender": { mountPath: webmentionSenderMountPath, timeout: webmentionSenderTimeout, diff --git a/package-lock.json b/package-lock.json index 6c0ec816..ab79c12b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,6 +23,7 @@ "@rmdes/indiekit-endpoint-posts": "^1.0.0-beta.25", "@rmdes/indiekit-endpoint-webmention-io": "^1.0.7", "@rmdes/indiekit-endpoint-webmention-sender": "^1.0.6", + "@rmdes/indiekit-endpoint-webmentions-proxy": "^1.0.3", "@rmdes/indiekit-post-type-page": "^1.0.4", "@rmdes/indiekit-preset-eleventy": "^1.0.0-beta.33", "@rmdes/indiekit-syndicator-bluesky": "^1.0.19", @@ -2518,6 +2519,21 @@ "url": "https://opencollective.com/node-fetch" } }, + "node_modules/@rmdes/indiekit-endpoint-webmentions-proxy": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rmdes/indiekit-endpoint-webmentions-proxy/-/indiekit-endpoint-webmentions-proxy-1.0.3.tgz", + "integrity": "sha512-lVaE/zy0HvDgyC4Lp9vOp7AaYFHAZdfXDuLBmrTD+j5TWi9U3/dzjKe0xRs9h7wo9jIyk+M7zAnWhLtaoY90OA==", + "license": "MIT", + "dependencies": { + "express": "^5.0.0" + }, + "engines": { + "node": ">=20" + }, + "peerDependencies": { + "@indiekit/indiekit": ">=1.0.0-beta.25" + } + }, "node_modules/@rmdes/indiekit-post-type-page": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@rmdes/indiekit-post-type-page/-/indiekit-post-type-page-1.0.4.tgz", diff --git a/package.json b/package.json index f3a53ef6..dcd9959e 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "@rmdes/indiekit-endpoint-posts": "^1.0.0-beta.25", "@rmdes/indiekit-endpoint-webmention-io": "^1.0.7", "@rmdes/indiekit-endpoint-webmention-sender": "^1.0.6", + "@rmdes/indiekit-endpoint-webmentions-proxy": "^1.0.3", "@rmdes/indiekit-post-type-page": "^1.0.4", "@rmdes/indiekit-preset-eleventy": "^1.0.0-beta.33", "@rmdes/indiekit-syndicator-bluesky": "^1.0.19",