feat: initial mini simple event sourcing for pending application updates
This commit is contained in:
18
joe.ts
18
joe.ts
@@ -3,14 +3,26 @@ 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";
|
||||
|
||||
console.log("Hello Pierrot!");
|
||||
// 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({
|
||||
@@ -29,7 +41,7 @@ const server = Bun.serve({
|
||||
case "/applications":
|
||||
return applications(req, caprover);
|
||||
case "/applications/update":
|
||||
return applicationsUpdate(req, caprover, dockerHub);
|
||||
return applicationsUpdate(req, caprover, dockerHub, queries);
|
||||
default:
|
||||
return new Response("Not Found", { status: 404 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user