Skip to content

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:

1
import '../seyfert.config.js'; // ye, importing our seyfert.config.js
2
import { HttpClient } from 'seyfert';
3
4
import Ping from './commands/ping.js';
5
6
const client = new HttpClient();
7
8
client.start()
9
.then(async () => {
10
// we need to load commands manually
11
await client.commands!.load('', client, [Ping]);
12
});
13
14
export default {
15
fetch(req: Request) {
16
return client.fetch(req);
17
}
18
}

and in the same when we load components and langs

1
import '../seyfert.config.js'; // ye, importing our seyfert.config.js
2
import { HttpClient } from 'seyfert';
3
4
// commands
5
import Ping from './commands/ping.js';
6
7
// langs
8
import EnLang from './languages/en.js';
9
10
// components
11
import ButtonC from './components/buttonHandle.js';
12
13
const client = new HttpClient();
14
15
client.start()
16
.then(async () => {
17
// we need to load commands manually
18
await client.commands!.load('', client, [Ping]);
19
20
// load languages
21
await client.langs!.load('', [{ name: 'en', file: EnLang}]);
22
23
// load components
24
await client.components!.load('', client, [ButtonC]);
25
});
26
27
export default {
28
fetch(req: Request) {
29
return client.fetch(req);
30
}
31
}

and we are ready to use seyfert with Cloudflare Workers.