feat: replace CLI script with web UI (Joe) for listing outdated applications
This commit is contained in:
39
joe.ts
Normal file
39
joe.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
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}`);
|
||||
Reference in New Issue
Block a user