Create basic author dispatcher

This commit is contained in:
Steffo 2024-10-17 03:46:40 +02:00
parent 88c68122a6
commit c002b0e1d1
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0

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(