Support for the basics of federation #1
1 changed files with 24 additions and 5 deletions
29
src/main.ts
29
src/main.ts
|
@ -1,15 +1,31 @@
|
||||||
import {createFederation} from "@fedify/fedify"
|
import {createFederation} 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 {RedisKvStore} from "https://jsr.io/@fedify/redis/0.3.0/src/kv.ts"
|
||||||
import {Redis} from "ioredis"
|
import {Redis} from "ioredis"
|
||||||
|
|
||||||
|
|
||||||
const federation = createFederation<void>({
|
await configure({
|
||||||
kv: new RedisKvStore(
|
sinks: {console: getConsoleSink()},
|
||||||
new Redis({}),
|
filters: {},
|
||||||
{},
|
loggers: [
|
||||||
),
|
{category: ["logtape", "meta"], sinks: ["console"], level: "warning"},
|
||||||
|
{category: ["fedify"], sinks: ["console"], level: "info"},
|
||||||
|
{category: ["dotino-veloce"], sinks: ["console"], level: "debug"},
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const l = getLogger(["dotino-veloce", "main"])
|
||||||
|
|
||||||
|
l.debug`Creating redis object...`
|
||||||
|
const redis = new Redis({})
|
||||||
|
|
||||||
|
l.debug`Creating federation object...`
|
||||||
|
const kv = new RedisKvStore(redis, {})
|
||||||
|
|
||||||
|
l.debug`Creating federation object...`
|
||||||
|
const federation = createFederation<void>({kv})
|
||||||
|
|
||||||
|
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(
|
||||||
request,
|
request,
|
||||||
|
@ -21,9 +37,12 @@ const handler: Deno.ServeHandler = function handler(request) {
|
||||||
return response
|
return response
|
||||||
};
|
};
|
||||||
|
|
||||||
|
l.info`Starting server...`
|
||||||
Deno.serve(
|
Deno.serve(
|
||||||
{
|
{
|
||||||
port: 8080,
|
port: 8080,
|
||||||
|
onListen: (_localAddr) => {
|
||||||
|
},
|
||||||
},
|
},
|
||||||
handler,
|
handler,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue