I find the microblog document has some notes about Recently, cloud edge functions like Cloudflare Workers have also gained popularity as JavaScript runtimes
Does Fedify expect to support it natively?
If I choose to use Cloudflare Workers, I need to use the Bindings feature to get the key-value store.
interface Bindings {
Cache: KVNamespace;
}
const app = new Hono<{ Bindings: Bindings }>()
// ...
app.use(federation(fedi, (ctx) => {
// the "ctx.env.Cache" is here
return // ...
}));
However, the Federation object is required kv and initialized before handling the request.
const fedi = createFederation<string>({
// ctx.env.Cache is not available yet
});
const app = new Hono();
app.use(federation(fedi, (ctx) => "context data"));
Or the expected usage is like this
interface Bindings {
Cache: KVNamespace;
}
const app = new Hono<{ Bindings: Bindings }>()
app.use(async (ctx, next) => {
const fedi = createFederation<string>({
kv: new MyKVStore(ctx.env.Cache)
});
ctx.set('fedi', fedi) // use this later
await next()
});
Creating a Federation instance for every request technically makes no problem, but I doubt that Fedify currently work well on Cloudflare Workers, as it's never tested on that. 🤔
Hi,
I find the microblog document has some notes about
Recently, cloud edge functions like Cloudflare Workers have also gained popularity as JavaScript runtimes
Does Fedify expect to support it natively?
If I choose to use Cloudflare Workers, I need to use the Bindings feature to get the key-value store.
However, the
Federation
object is requiredkv
and initialized before handling the request.Or the expected usage is like this