Recipes
Using Cloudflare Workers
Seyfert supports Cloudflare Workers, you can setup it by configuring seyfert.config.mjs with config.http see more info here
Since Cloudflare Workers doesn't support fs, using it with seyfert might be a little tricky as you may have to import each command/language/component and load it manually
You must set compilerOptions.module to ESNext in your tsconfig.json since cf workers only supports ESM
First of all you will need to install the generic adapter for seyfert, you can do it by running:
npm add @slipher/generic-adapterand your index.ts shall follow the following example, loading commands, langs and components manually:
import '../seyfert.config.mjs'; // ye, importing our seyfert.config.mjs
import { HttpClient } from 'seyfert';
import { GenericAdapter } from '@slipher/generic-adapter';
// commands
import Ping from './commands/ping.js';
// langs
import EnLang from './languages/en.js';
// components
import ButtonC from './components/buttonHandle.js';
const client = new HttpClient();
const adapter = new GenericAdapter(client);
const ready = client.start()
.then(async () => {
// we need to load commands manually
client.commands.set([Ping]);
// load languages
client.langs.set([{ name: 'en', file: EnLang }]);
// load components
client.components.set([ButtonC]);
})
.then(() => adapter.start());
export default {
async fetch(req: Request) {
await ready;
return adapter.fetch(req);
}
}and then onwards we can use seyfert with Cloudflare Workers.