Skip to content

Commit

Permalink
feat(endpoint-webmention-io): webmention.io endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Dec 25, 2024
1 parent 9bb8388 commit 9ceb623
Show file tree
Hide file tree
Showing 27 changed files with 1,350 additions and 5,457 deletions.
3 changes: 3 additions & 0 deletions helpers/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,8 @@ export const testConfig = async (options) => {
user: "username",
accessToken: "abcd1234",
},
"@indiekit/endpoint-webmention-io": {
token: "abcd1234",
},
};
};
57 changes: 57 additions & 0 deletions helpers/mock-agent/endpoint-webmention-io.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { MockAgent } from "undici";

/**
* @returns {import("undici").MockAgent} Undici MockAgent
* @see {@link https://undici.nodejs.org/#/docs/api/MockAgent}
*/
export function mockClient() {
const agent = new MockAgent();
agent.disableNetConnect();
agent.enableNetConnect(/(?:127\.0\.0\.1:\d{5})/);

const origin = "https://webmention.io";

agent
.get(origin)
.intercept({
path: "/api/mentions.jf2",
query: {
token: "abcd1234",
domain: "website.example",
"per-page": 20,
},
})
.reply(200, {
type: "feed",
name: "Webmentions",
children: [
{
type: "entry",
author: {
type: "card",
name: "Example",
url: "https://person.example",
},
url: "https://person.example/likes/1/",
published: "2024-12-25T19:00:00+00:00",
"wm-received": "2024-12-25T19:00:00+00:00",
"wm-id": 1,
"wm-source": "https://person.example/likes/1/",
"wm-target": "https://getindiekit.com",
"wm-protocol": "webmention",
content: {
"content-type": "text/html",
value: "<p>This looks interesting.</p>",
html: "<p>This looks interesting.</p>",
text: "This looks interesting.",
},
"like-of": "https://getindiekit.com",
"wm-property": "like-of",
"wm-private": false,
},
],
})
.persist();

return agent;
}
1 change: 1 addition & 0 deletions indiekit.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const config = {
plugins: [
"@indiekit-test/frontend",
"@indiekit/endpoint-json-feed",
"@indiekit/endpoint-webmention-io",
"@indiekit/post-type-audio",
"@indiekit/post-type-event",
"@indiekit/post-type-jam",
Expand Down
6 changes: 6 additions & 0 deletions localazy.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
"pattern": "packages/endpoint-share/locales/en.json",
"module": "endpoint-share"
},
{
"file": "en.json",
"path": "packages/endpoint-webmention-io/locales",
"pattern": "packages/endpoint-webmention-io/locales/en.json",
"module": "endpoint-webmention-io"
},
{
"file": "en.json",
"path": "packages/error/locales",
Expand Down
Loading

0 comments on commit 9ceb623

Please sign in to comment.