You connect small islands to one another all at once. Instead of writing letter by letter to each one, subscribe to a lighthouse and the sea's news arrives in a batch. For a sparsely populated island, whether a relay exists changes the whole experience of federation—and this is the kit for building that lighthouse yourself.
Offshore there are two styles, Mastodon and LitePub, and their subscription handshakes differ slightly. So this lighthouse wears both faces at once.
Highlights
- Both subscribing and unsubscribing are the Follow handshake (follow.ts)—the lighthouse, too, is an actor.
- Both styles come with tests (mastodon.test.ts / litepub.test.ts).
- About 2,900 lines. A lighthouse kit for any island that wants to build its own relay server.
A passage from the sutra
export function createRelay(
type: RelayType,
options: RelayOptions,
): Relay {
switch (type) {
case "mastodon":
return new MastodonRelay(options, relayBuilder);
case "litepub":
return new LitePubRelay(options, relayBuilder);
}
}