diff --git a/src/http/HttpServer.ts b/src/http/HttpServer.ts index 4b5de04..ed21933 100644 --- a/src/http/HttpServer.ts +++ b/src/http/HttpServer.ts @@ -17,8 +17,9 @@ const HTTPS_CONFIG = { export default class HttpServer { private readonly server; + public static instance: HttpServer; - public constructor() { + private constructor() { this.server = express(); this.server.use(express.json()); 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}`); }); } + + public static getInstance(): HttpServer { + if (!HttpServer.instance) { + HttpServer.instance = new HttpServer(); + } + return HttpServer.instance; + } } \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index fd60d52..a6c8973 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,4 +10,4 @@ const c = new Logger("CrepeSR"); c.log(`Starting CrepeSR...`); Interface.start(); -const http = new HttpServer(); \ No newline at end of file +HttpServer.getInstance(); \ No newline at end of file