import Caprover from "./services/Caprover"; import applications from "./routes/applications"; import applicationsUpdate from "./routes/applications.update"; import Layout, { html } from "./ui/Layout"; import DockerHub from "./services/DockerHub"; import FileEventStore from "./infrastructure/FileEventStore"; import AppQueries from "./domain/AppQueries"; import AppProjections from "./domain/AppProjections"; // Domain const eventStore = new FileEventStore("./data/events.jsonl"); const projections = new AppProjections(); const queries = new AppQueries(projections); projections.getAll().forEach((projection) => { eventStore.subscribe(projection); }); await eventStore.replay(); // External services const caprover = new Caprover( eventStore, process.env.CAPTAIN_DOMAIN, process.env.CAPTAIN_PASSWORD ); const dockerHub = new DockerHub(); const server = Bun.serve({ port: 3000, fetch(req: Request) { const url = new URL(req.url); switch (url.pathname) { case "/": return new Response( Layout( html`
I'm Joe, your personal assistant.
` ), { headers: { "Content-Type": "text/html" } } ); case "/applications": return applications(req, caprover); case "/applications/update": return applicationsUpdate(req, caprover, dockerHub, queries); default: return new Response("Not Found", { status: 404 }); } }, }); console.log(`Server started at http://${server.hostname}:${server.port}`);