Using Cloudflare Workers
Seyfert supports Cloudflare Workers, you can setup it by configuring seyfert.config.mjs
with config.http
see more info here
First of all you will need to install an adapter for seyfert, you can do it by running:
npm add @slipher/generic-adapter
and your index.ts
shall follow the following example:
import '../seyfert.config.mjs'; // ye, importing our seyfert.config.mjsimport { HttpClient } from 'seyfert';import { GenericAdapter } from '@slipher/generic-adapter';
import Ping from './commands/ping.js';
const client = new HttpClient();const adapter = new GenericAdapter(client);
client.start() .then(async () => { // we need to load commands manually await client.commands!.set('', client, [Ping]); });
adapter.start();
export default { fetch(req: Request) { return adapter.fetch(req); }}
and the same when we load both components
and langs
import '../seyfert.config.mjs'; // ye, importing our seyfert.config.mjsimport { HttpClient } from 'seyfert';
// commandsimport Ping from './commands/ping.js';
// langsimport EnLang from './languages/en.js';
// componentsimport ButtonC from './components/buttonHandle.js';
const client = new HttpClient();
client.start() .then(async () => { // we need to load commands manually await client.commands!.set('', client, [Ping]);
// load languages await client.langs!.set('', [{ name: 'en', file: EnLang}]);
// load components await client.components!.set('', client, [ButtonC]); });
adapter.start();
export default { fetch(req: Request) { return adapter.fetch(req); }}
and then onwards we can use seyfert with Cloudflare Workers.