mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Add ExpressHttpServerFactory.
This commit is contained in:
committed by
Joachim Van Herwegen
parent
4ef4d44a3a
commit
e39e7963eb
@@ -4,8 +4,9 @@ import type { Express } from 'express';
|
||||
import express from 'express';
|
||||
import { getLoggerFor } from '../logging/LogUtil';
|
||||
import type { HttpHandler } from './HttpHandler';
|
||||
import type { HttpServerFactory } from './HttpServerFactory';
|
||||
|
||||
export class ExpressHttpServer {
|
||||
export class ExpressHttpServerFactory implements HttpServerFactory {
|
||||
protected readonly logger = getLoggerFor(this);
|
||||
|
||||
private readonly handler: HttpHandler;
|
||||
@@ -14,7 +15,7 @@ export class ExpressHttpServer {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public listen(port?: number): Server {
|
||||
public startServer(port: number): Server {
|
||||
const app = express();
|
||||
this.setup(app);
|
||||
return app.listen(port);
|
||||
8
src/server/HttpServerFactory.ts
Normal file
8
src/server/HttpServerFactory.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { Server } from 'http';
|
||||
|
||||
/**
|
||||
* A factory for HTTP servers
|
||||
*/
|
||||
export interface HttpServerFactory {
|
||||
startServer: (port: number) => Server;
|
||||
}
|
||||
Reference in New Issue
Block a user