Initial Commit
This commit is contained in:
40
src/app.ts
Normal file
40
src/app.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { HTTPService } from './services/http-router';
|
||||
import { InvitationsRoute } from './routes/invitations';
|
||||
import { InvitationStore } from './services/invitation-store';
|
||||
import { SSEBroadcaster } from './services/sse-broadcast';
|
||||
|
||||
export class App {
|
||||
static async create() {
|
||||
// Create the invitation store (this is a in-memory store for now)
|
||||
const invitationStore = new InvitationStore();
|
||||
|
||||
// Create the SSE Broadcaster
|
||||
const sseBroadcaster = new SSEBroadcaster();
|
||||
|
||||
// Create the Invitation route, passing in the invitation store and sse broadcaster
|
||||
const invitationsRoute = new InvitationsRoute(invitationStore, sseBroadcaster);
|
||||
|
||||
// Create the HTTP service, passing in the invitation route
|
||||
const http = new HTTPService([
|
||||
invitationsRoute,
|
||||
]);
|
||||
|
||||
// Create the app instance, passing in the HTTP service
|
||||
return new App(http);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of App.
|
||||
* @param http - The HTTP service instance.
|
||||
*/
|
||||
constructor(private readonly http: HTTPService) {}
|
||||
|
||||
async start() {
|
||||
// Start the HTTP service
|
||||
await this.http.start();
|
||||
}
|
||||
}
|
||||
|
||||
// Create the app instance and start it
|
||||
const app = await App.create();
|
||||
await app.start();
|
||||
Reference in New Issue
Block a user