Make HttpServer singleton-based
This commit is contained in:
parent
203a6b9fa2
commit
8779554ed2
@ -17,8 +17,9 @@ const HTTPS_CONFIG = {
|
|||||||
|
|
||||||
export default class HttpServer {
|
export default class HttpServer {
|
||||||
private readonly server;
|
private readonly server;
|
||||||
|
public static instance: HttpServer;
|
||||||
|
|
||||||
public constructor() {
|
private constructor() {
|
||||||
this.server = express();
|
this.server = express();
|
||||||
this.server.use(express.json());
|
this.server.use(express.json());
|
||||||
this.server.route('/*').all((req, res) => {
|
this.server.route('/*').all((req, res) => {
|
||||||
@ -39,4 +40,11 @@ export default class HttpServer {
|
|||||||
c.log(`Listening on ${Config.HTTP.HTTP_HOST}:${Config.HTTP.HTTP_PORT}`);
|
c.log(`Listening on ${Config.HTTP.HTTP_HOST}:${Config.HTTP.HTTP_PORT}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static getInstance(): HttpServer {
|
||||||
|
if (!HttpServer.instance) {
|
||||||
|
HttpServer.instance = new HttpServer();
|
||||||
|
}
|
||||||
|
return HttpServer.instance;
|
||||||
|
}
|
||||||
}
|
}
|
@ -10,4 +10,4 @@ const c = new Logger("CrepeSR");
|
|||||||
|
|
||||||
c.log(`Starting CrepeSR...`);
|
c.log(`Starting CrepeSR...`);
|
||||||
Interface.start();
|
Interface.start();
|
||||||
const http = new HttpServer();
|
HttpServer.getInstance();
|
Loading…
Reference in New Issue
Block a user