Support for the basics of federation #1
1 changed files with 19 additions and 1 deletions
20
src/main.ts
20
src/main.ts
|
@ -1,4 +1,4 @@
|
|||
import {createFederation} from "@fedify/fedify"
|
||||
import {createFederation, Service} from "@fedify/fedify"
|
||||
import {configure, getConsoleSink, getLogger} from "@logtape/logtape"
|
||||
import {RedisKvStore} from "https://jsr.io/@fedify/redis/0.3.0/src/kv.ts"
|
||||
import {Redis} from "ioredis"
|
||||
|
@ -25,6 +25,24 @@ const kv = new RedisKvStore(redis, {})
|
|||
l.debug`Creating federation object...`
|
||||
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...`
|
||||
const handler: Deno.ServeHandler = function handler(request) {
|
||||
const response = federation.fetch(
|
||||
|
|
Loading…
Reference in a new issue