refactor: Split off ServerInitializer.

This commit is contained in:
Ruben Verborgh
2020-12-07 22:33:37 +01:00
committed by Joachim Van Herwegen
parent b0ecf1c1d8
commit 04a91858c2
8 changed files with 55 additions and 48 deletions

View File

@@ -0,0 +1,20 @@
import type { HttpServerFactory } from '../server/HttpServerFactory';
import { Initializer } from './Initializer';
/**
* Creates and starts an HTTP server.
*/
export class ServerInitializer extends Initializer {
private readonly serverFactory: HttpServerFactory;
private readonly port: number;
public constructor(serverFactory: HttpServerFactory, port: number) {
super();
this.serverFactory = serverFactory;
this.port = port;
}
public async handle(): Promise<void> {
this.serverFactory.startServer(this.port);
}
}