This commit is contained in:
Erik 2023-05-15 22:02:41 +03:00
parent 4ac0e9a084
commit 3581ee12ab
Signed by: Navy.gif
GPG Key ID: 2532FBBB61C65A68
2 changed files with 7 additions and 5 deletions

View File

@ -268,8 +268,9 @@ class Server extends EventEmitter {
}
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
#logError (err: Error, _req: Request, res: Response, _next: NextFunction) {
#logError (err: Error, req: Request, res: Response, _next: NextFunction) {
this.#logger.error(`Unhandled error:\n${err.stack || err}`);
if (!req.complete)
res.status(500).send('An internal error was encountered');
}
@ -295,7 +296,7 @@ class Server extends EventEmitter {
this.#_ready = false;
// Close http server first and allow it to finish serving requests
if (this.#_server)
if (this.#_server) {
this.#_server.close(async () => {
await this.#_mongodb.close();
await this.#_mariadb.close();
@ -307,6 +308,7 @@ class Server extends EventEmitter {
// eslint-disable-next-line no-process-exit
process.exit();
});
}
}

View File

@ -35,7 +35,7 @@ class Home extends Endpoint {
async home (_req: Request, res: Response) {
if (this.server.serveFiles && existsSync(path.join(this.server.serveFiles, '/build/index.html')))
res.sendFile('/build/index.html', { root: this.server.serveFiles });
return res.sendFile('/build/index.html', { root: this.server.serveFiles });
return res.status(404).end();
}