mirror of
https://github.com/versia-pub/server.git
synced 2026-04-27 20:59:15 +02:00
refactor(api): ♻️ Use Web Workers instead of spawning the same process once for each thread
This commit is contained in:
parent
bc8220c8f9
commit
d29603275a
7 changed files with 213 additions and 164 deletions
22
utils/server.ts
Normal file
22
utils/server.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import type { Config } from "config-manager";
|
||||
import type { Hono } from "hono";
|
||||
|
||||
export const createServer = (config: Config, app: Hono) =>
|
||||
Bun.serve({
|
||||
port: config.http.bind_port,
|
||||
reusePort: true,
|
||||
tls: config.http.tls.enabled
|
||||
? {
|
||||
key: Bun.file(config.http.tls.key),
|
||||
cert: Bun.file(config.http.tls.cert),
|
||||
passphrase: config.http.tls.passphrase,
|
||||
ca: config.http.tls.ca
|
||||
? Bun.file(config.http.tls.ca)
|
||||
: undefined,
|
||||
}
|
||||
: undefined,
|
||||
hostname: config.http.bind || "0.0.0.0", // defaults to "0.0.0.0"
|
||||
fetch(req, server) {
|
||||
return app.fetch(req, { ip: server.requestIP(req) });
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue