Skip to main content
This release is a pre-release — the latest non-prerelease version of @fedify/fedify is 0.11.3. Jump to this version

@fedify/fedify@0.12.0-dev.278+8699f21b
Built and signed on GitHub Actions

An ActivityPub/fediverse server framework

This package works with Node.js, Deno, Bun
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
100%
Published
2 weeks ago (0.12.0-dev.278+8699f21b)
class Federation

An object that registers federation-related business logic and dispatches requests to the appropriate handlers.

It also provides a middleware interface for handling requests before your web framework's router; see Federation.handle.

Constructors

new
Federation(parameters: FederationParameters)

Create a new Federation instance.

Type Parameters

TContextData

Methods

Create a new context.

Create a new context for a request.

Handles a request related to federation. If a request is not related to federation, the onNotFound or onNotAcceptable callback is called.

Usually, this method is called from a server's request handler or a web framework's middleware.

deprecated
sendActivity(
keys: SenderKeyPair[],
recipients: Recipient | Recipient[],
activity: Activity,
options: SendActivityInternalOptions<TContextData>,
): Promise<void>

Sends an activity to recipients' inboxes. You would typically use Context.sendActivity instead of this method.

Registers an actor dispatcher.

Registers a featured collection dispatcher.

Registers a featured tags collection dispatcher.

Registers a followers collection dispatcher.

Registers a following collection dispatcher.

Registers an inbox dispatcher.

setInboxListeners(
inboxPath: `${string}{handle}${string}`,
sharedInboxPath?: string,
): InboxListenerSetters<TContextData>

Assigns the URL path for the inbox and starts setting inbox listeners.

Registers a liked collection dispatcher.

Registers a NodeInfo dispatcher.

setObjectDispatcher<
TObject extends Object,
TParam extends string,
>
(
cls: (new (...args: any[]) => TObject) & { typeId: URL; },
path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`,
dispatcher: ObjectDispatcher<TContextData, TObject, TParam>,
): ObjectCallbackSetters<TContextData, TObject, TParam>

Registers an object dispatcher.

setObjectDispatcher<
TObject extends Object,
TParam extends string,
>
(
cls: (new (...args: any[]) => TObject) & { typeId: URL; },
path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`,
dispatcher: ObjectDispatcher<TContextData, TObject, TParam>,
): ObjectCallbackSetters<TContextData, TObject, TParam>

Registers an object dispatcher.

setObjectDispatcher<
TObject extends Object,
TParam extends string,
>
(
cls: (new (...args: any[]) => TObject) & { typeId: URL; },
path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`,
dispatcher: ObjectDispatcher<TContextData, TObject, TParam>,
): ObjectCallbackSetters<TContextData, TObject, TParam>

Registers an object dispatcher.

setObjectDispatcher<
TObject extends Object,
TParam extends string,
>
(
cls: (new (...args: any[]) => TObject) & { typeId: URL; },
path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`,
dispatcher: ObjectDispatcher<TContextData, TObject, TParam>,
): ObjectCallbackSetters<TContextData, TObject, TParam>

Registers an object dispatcher.

setObjectDispatcher<
TObject extends Object,
TParam extends string,
>
(
cls: (new (...args: any[]) => TObject) & { typeId: URL; },
path: `${string}{${TParam}}${string}{${TParam}}${string}`,
dispatcher: ObjectDispatcher<TContextData, TObject, TParam>,
): ObjectCallbackSetters<TContextData, TObject, TParam>

Registers an object dispatcher.

setObjectDispatcher<
TObject extends Object,
TParam extends string,
>
(
cls: (new (...args: any[]) => TObject) & { typeId: URL; },
path: `${string}{${TParam}}${string}`,
dispatcher: ObjectDispatcher<TContextData, TObject, TParam>,
): ObjectCallbackSetters<TContextData, TObject, TParam>

Registers an object dispatcher.

Registers an outbox dispatcher.

startQueue(contextData: TContextData): Promise<void>

Manually start the task queue.

This method is useful when you set the manuallyStartQueue option to true in the createFederation function.

Add Package

deno add @fedify/fedify

Import symbol

import { Federation } from "@fedify/fedify/federation";

Add Package

npx jsr add @fedify/fedify

Import symbol

import { Federation } from "@fedify/fedify/federation";

Add Package

yarn dlx jsr add @fedify/fedify

Import symbol

import { Federation } from "@fedify/fedify/federation";

Add Package

pnpm dlx jsr add @fedify/fedify

Import symbol

import { Federation } from "@fedify/fedify/federation";

Add Package

bunx jsr add @fedify/fedify

Import symbol

import { Federation } from "@fedify/fedify/federation";