40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
|
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";
|
||
|
|
||
|
console.log("Hello Pierrot!");
|
||
|
|
||
|
const caprover = new Caprover(
|
||
|
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`<h1>Hello World.</h1>
|
||
|
<p>I'm Joe, your personal assistant.</p>`
|
||
|
),
|
||
|
{ headers: { "Content-Type": "text/html" } }
|
||
|
);
|
||
|
case "/applications":
|
||
|
return applications(req, caprover);
|
||
|
case "/applications/update":
|
||
|
return applicationsUpdate(req, caprover, dockerHub);
|
||
|
default:
|
||
|
return new Response("Not Found", { status: 404 });
|
||
|
}
|
||
|
},
|
||
|
});
|
||
|
|
||
|
console.log(`Server started at http://${server.hostname}:${server.port}`);
|