Support for the basics of federation #1

Merged
steffo merged 8 commits from feature/basics into main 2024-10-17 22:48:14 +00:00
Showing only changes of commit c002b0e1d1 - Show all commits

View file

@ -1,4 +1,4 @@
import {createFederation} from "@fedify/fedify" import {createFederation, Service} from "@fedify/fedify"
import {configure, getConsoleSink, getLogger} from "@logtape/logtape" import {configure, getConsoleSink, getLogger} from "@logtape/logtape"
import {RedisKvStore} from "https://jsr.io/@fedify/redis/0.3.0/src/kv.ts" import {RedisKvStore} from "https://jsr.io/@fedify/redis/0.3.0/src/kv.ts"
import {Redis} from "ioredis" import {Redis} from "ioredis"
@ -25,6 +25,24 @@ const kv = new RedisKvStore(redis, {})
l.debug`Creating federation object...` l.debug`Creating federation object...`
const federation = createFederation<void>({kv}) const federation = createFederation<void>({kv})
l.debug`Creating actor dispatcher...`
const actorDispatcher = async function actorDispatcher(ctx: any, id: string) {
if(id !== "service") {
return null
}
return new Service({
id: ctx.getActorUri(id),
name: "[TEST] Dotino Service",
summary: "Core account of a Dotino Veloce instance.",
preferredUsername: id,
url: new URL("/", ctx.url),
})
}
l.debug`Connecting actor dispatcher to federation object...`
federation.setActorDispatcher("/users/{identifier}", actorDispatcher)
l.debug`Creating Deno handler...` l.debug`Creating Deno handler...`
const handler: Deno.ServeHandler = function handler(request) { const handler: Deno.ServeHandler = function handler(request) {
const response = federation.fetch( const response = federation.fetch(