-
Hi, I find the microblog document has some notes about 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 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()
});
|
Beta Was this translation helpful? Give feedback.
Replies: 15 comments 1 reply
-
Creating a |
Beta Was this translation helpful? Give feedback.
-
I will test it before I start my project. If I encounter any problems, I will report them or make a PR. |
Beta Was this translation helpful? Give feedback.
-
Tested with Cloudflare Workers (local dev mode) but the
It seems some packages or features are not supported by Cloudflare Worker. Is it possible to avoid using shim in Fedify for better capabilities? |
Beta Was this translation helpful? Give feedback.
-
We're willing to support edge functions including Cloudflare Workers in a long term, but I guess it wouldn't be trivial in a short term… 😭 One cloud edge function I've tested with Fedify is Deno Deploy at the moment. |
Beta Was this translation helpful? Give feedback.
-
Ah, Fedify on JSR would work better with edge functions. |
Beta Was this translation helpful? Give feedback.
-
Switching to
|
Beta Was this translation helpful? Give feedback.
-
Updated: Fixed, the typo caused the web finger not to return anything. I can run it correctly after adding polyfill. According to the tutorial - https://fedify.dev/tutorial/basics#actor-dispatcher I can call |
Beta Was this translation helpful? Give feedback.
-
Could you try a polyfill for Temporal API? |
Beta Was this translation helpful? Give feedback.
-
@elct9620, shouldn't Also, did you manage to get Fedify working with Cloudflare Workers? |
Beta Was this translation helpful? Give feedback.
-
I got Fedify working on Cloudflare Workers by
For the last one, I used this dirty solution: // package.json
{
"scripts": {
+ "prepare": "node ./patch-fedify-for-workers.js"
}
} // patch-fedify-for-workers.js
import { glob, readFile, writeFile } from 'node:fs/promises';
import { join } from 'node:path';
const cwd = 'node_modules/@fedify/fedify';
const codeToDelete = ' with {\n type: "json"\n}';
for await (const entry of glob('*/*.js', { cwd })) {
(async () => {
const filePath = join(cwd, entry);
const originalContent = await readFile(filePath, 'utf8');
const patchedContent = originalContent.replace(codeToDelete, '');
if (originalContent !== patchedContent) {
await writeFile(filePath, patchedContent);
}
})();
} The This could be done better with esbuild, but I think this is good enough for myself as a temporary solution. I assume Workers will eventually support import attributes (and the Temporal API as well). |
Beta Was this translation helpful? Give feedback.
-
The upcoming major version 4 of wrangler supports import attributes. You can install a prerelease version by running Footnotes |
Beta Was this translation helpful? Give feedback.
-
Good news! We've officially added Cloudflare Workers support to the Fedify roadmap. I've created a detailed issue to track our implementation plan: The effort will be tackled in phases, including compatibility assessment, core adaptations for Workers' environment, KV store and message queue implementations, and finally integration with Cloudflare's ecosystem. This will be a substantial project that we'll break down into several sub-issues. Thank you everyone who expressed interest in this feature. Your input from this discussion has been valuable in shaping our approach. We welcome community contributions and feedback as we move forward with implementation. If you're interested in contributing to any specific aspect of Workers support, please comment on the main issue to coordinate efforts. |
Beta Was this translation helpful? Give feedback.
-
First milestone reached! PR #239 successfully implements a comprehensive test environment for Cloudflare Workers using Miniflare. Our test suite (with some exclusions) now passes in the Workers runtime environment. This establishes the foundation for testing cross-runtime compatibility and validates that the core Fedify functionality can work on Workers. Next steps include addressing the remaining test failures and implementing Workers-specific components. |
Beta Was this translation helpful? Give feedback.
-
🎉 Cloudflare Workers support is now complete! After implementing the test infrastructure, core module, examples, and comprehensive documentation, Fedify can now run on Cloudflare Workers. What's included:
Try it now: Available in the development release v1.6.1-dev.876+7b07d213:
This will be included in the upcoming Fedify 1.6 stable release. Thank you to everyone who requested this feature and provided feedback throughout the implementation! |
Beta Was this translation helpful? Give feedback.
-
Fedify 1.6.1, which supports Cloudflare Workers, was released. |
Beta Was this translation helpful? Give feedback.
🎉 Cloudflare Workers support is now complete! After implementing the test infrastructure, core module, examples, and comprehensive documentation, Fedify can now run on Cloudflare Workers.
What's included:
@fedify/fedify/x/cfworkers
module withWorkersKvStore
andWorkersMessageQueue
Try it now: Available in the development release v1.6.1-dev.876+7b07d213:
This will be included in the upcoming Fedify 1.6 stable r…