forked from syntaxbullet/AuroraBot-discord
feat(web): implement web server foundation
This commit is contained in:
24
src/web/server.ts
Normal file
24
src/web/server.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { env } from "@/lib/env";
|
||||
import { router } from "./router";
|
||||
import type { Server } from "bun";
|
||||
|
||||
export class WebServer {
|
||||
private static server: Server<any> | null = null;
|
||||
|
||||
public static start() {
|
||||
this.server = Bun.serve({
|
||||
port: env.PORT || 3000,
|
||||
fetch: router,
|
||||
});
|
||||
|
||||
console.log(`🌐 Web server listening on http://localhost:${this.server.port}`);
|
||||
}
|
||||
|
||||
public static stop() {
|
||||
if (this.server) {
|
||||
this.server.stop();
|
||||
console.log("🛑 Web server stopped");
|
||||
this.server = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user