Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ To be released.
`FederationOptions` interface in favor of `documentLoaderFactory` option
for better flexibility. [[#376], [#393] by Hasang Cho]

- Remove `CreateFederationOptions<TContextData>` interface (which was
deprecated since 1.6.0). Use `FederationOptions<TContextData>` instead.
[[#376]]

- Remove `fetchDocumentLoader()` function (which was deprecated since 0.14.0).
Use `getDocumentLoader()` from `@fedify/vocab-runtime` instead. [[#376]]

- Remove `{ handle: string }` parameter form from `sendActivity()`,
`forwardActivity()`, `getDocumentLoader()`, and `ParseUriResult`.
Use `{ identifier: string }` or `{ username: string }` instead. [[#376]]

- Changed NodeInfo `software.version` field type from `SemVer` to `string`
to properly handle non-SemVer version strings in accordance with the
NodeInfo specification. [[#366], [#433] by Hyeonseo Kim]
Expand Down
14 changes: 7 additions & 7 deletions docs/manual/federation.md
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ export const builder = createFederationBuilder<void>();

// Register your dispatchers and listeners here...
builder.setActorDispatcher(
"/users/{handle}",
async (ctx, handle) => {
"/users/{identifier}",
async (ctx, identifier) => {
// Omitted for brevity
}
);
Expand Down Expand Up @@ -499,8 +499,8 @@ import { Person } from "@fedify/vocab";
const builder = null as unknown as FederationBuilder<void>;
// ---cut-before---
builder.setActorDispatcher(
"/users/{handle}",
async (ctx, handle) => {
"/users/{identifier}",
async (ctx, identifier) => {
const federation = ctx.federation; // Access the `Federation` object
// Omitted for brevity
// ---cut-start---
Expand Down Expand Up @@ -853,7 +853,7 @@ parameter within the `Context` object:
import { type Federation } from "@fedify/fedify";
const federation = null as unknown as Federation<void>;
// ---cut-before---
federation.setActorDispatcher("/users/{handle}", async (ctx, handle) => {
federation.setActorDispatcher("/users/{identifier}", async (ctx, identifier) => {
// There is a database connection in `ctx.data`.
});
~~~~
Expand Down Expand Up @@ -882,8 +882,8 @@ the virtual host information:
import { type Federation } from "@fedify/fedify";
const federation = null as unknown as Federation<void>;
// ---cut-before---
federation.setActorDispatcher("/@{handle}", (ctx, handle) => {
const fullHandle = `${handle}@${ctx.host}`;
federation.setActorDispatcher("/@{identifier}", (ctx, identifier) => {
const fullHandle = `${identifier}@${ctx.host}`;
// Omitted for brevity
});
~~~~
Expand Down
10 changes: 5 additions & 5 deletions docs/manual/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ and port.

For example, if you make a request to */.well-known/webfinger* Fedify will
handle the request by itself, but if you make a request to */users/alice*
(assuming your web framework has a handler for `/users/:handle`) with
(assuming your web framework has a handler for `/users/:identifier`) with
`Accept: text/html` header, Fedify will dispatch the request to the web
framework's appropriate handler for `/users/:handle`. Or if you define an
actor dispatcher for `/users/{handle}` in Fedify, and the request is made with
`Accept: application/activity+json` header, Fedify will dispatch the request to
the appropriate actor dispatcher.
framework's appropriate handler for `/users/:identifier`. Or if you define an
actor dispatcher for `/users/{identifier}` in Fedify, and the request is made
with `Accept: application/activity+json` header, Fedify will dispatch the
request to the appropriate actor dispatcher.

Here is a diagram that illustrates the architecture:

Expand Down
8 changes: 4 additions & 4 deletions examples/express/federation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ export const federation = createFederation<void>({
kv: new MemoryKvStore(),
});

federation.setActorDispatcher("/users/{handle}", (ctx, handle) => {
federation.setActorDispatcher("/users/{identifier}", (ctx, identifier) => {
return new Person({
id: ctx.getActorUri(handle),
preferredUsername: handle,
id: ctx.getActorUri(identifier),
preferredUsername: identifier,
});
});

federation.setObjectDispatcher(
Note,
"/users/{handle}/{id}",
"/users/{identifier}/{id}",
(ctx, values) => {
return new Note({
id: ctx.getObjectUri(Note, values),
Expand Down
4 changes: 2 additions & 2 deletions examples/express/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ app.set("trust proxy", true);

app.use(integrateFederation(federation, () => undefined));

app.get("/users/:handle", (req, res) => {
res.type("html").send(`<p>Hello, ${req.params.handle}!</p>`);
app.get("/users/:identifier", (req, res) => {
res.type("html").send(`<p>Hello, ${req.params.identifier}!</p>`);
});

app.listen(3000, () => {
Expand Down
8 changes: 4 additions & 4 deletions examples/h3/federation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ export const federation = createFederation<void>({
kv: new MemoryKvStore(),
});

federation.setActorDispatcher("/users/{handle}", (ctx, handle) => {
federation.setActorDispatcher("/users/{identifier}", (ctx, identifier) => {
return new Person({
id: ctx.getActorUri(handle),
preferredUsername: handle,
id: ctx.getActorUri(identifier),
preferredUsername: identifier,
});
});

federation.setObjectDispatcher(
Note,
"/users/{handle}/{id}",
"/users/{identifier}/{id}",
(ctx, values) => {
return new Note({
id: ctx.getObjectUri(Note, values),
Expand Down
4 changes: 2 additions & 2 deletions examples/h3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ const router = createRouter();
app.use(router);

router.get(
"/users/:handle",
"/users/:identifier",
defineEventHandler((event) => {
setResponseHeader(event, "Content-Type", "text/html");
return `<h1>Hello ${event.context.params?.["handle"]}</h1>`;
return `<h1>Hello ${event.context.params?.["identifier"]}</h1>`;
}),
);

Expand Down
8 changes: 4 additions & 4 deletions examples/koa/federation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ export const federation = createFederation<void>({
kv: new MemoryKvStore(),
});

federation.setActorDispatcher("/users/{handle}", (ctx, handle) => {
federation.setActorDispatcher("/users/{identifier}", (ctx, identifier) => {
return new Person({
id: ctx.getActorUri(handle),
preferredUsername: handle,
id: ctx.getActorUri(identifier),
preferredUsername: identifier,
});
});

federation.setObjectDispatcher(
Note,
"/users/{handle}/{id}",
"/users/{identifier}/{id}",
(ctx, values) => {
return new Note({
id: ctx.getObjectUri(Note, values),
Expand Down
Loading
Loading