Using Cloudflare Workers
Seyfert supports Cloudflare Workers, you can setup it by configuring seyfert.config.js
with config.http
see more info here
and your index.ts
should follow the next example:
1import '../seyfert.config.js'; // ye, importing our seyfert.config.js2import { HttpClient } from 'seyfert';3
4import Ping from './commands/ping.js';5
6const client = new HttpClient();7
8client.start()9 .then(async () => {10 // we need to load commands manually11 await client.commands!.load('', client, [Ping]);12 });13
14export default {15 fetch(req: Request) {16 return client.fetch(req);17 }18}
and in the same when we load components
and langs
1import '../seyfert.config.js'; // ye, importing our seyfert.config.js2import { HttpClient } from 'seyfert';3
4// commands5import Ping from './commands/ping.js';6
7// langs8import EnLang from './languages/en.js';9
10// components11import ButtonC from './components/buttonHandle.js';12
13const client = new HttpClient();14
15client.start()16 .then(async () => {17 // we need to load commands manually18 await client.commands!.load('', client, [Ping]);19
20 // load languages21 await client.langs!.load('', [{ name: 'en', file: EnLang}]);22
23 // load components24 await client.components!.load('', client, [ButtonC]);25 });26
27export default {28 fetch(req: Request) {29 return client.fetch(req);30 }31}
and we are ready to use seyfert with Cloudflare Workers.