try to fix this spaghetti of a code

This commit is contained in:
Frederik Spirgi
2026-09-09 11:02:31 +02:00
parent c0eb11c8d4
commit 45eef9ef5c
4 changed files with 7 additions and 6 deletions
+3 -2
View File
@@ -1,4 +1,4 @@
const http = require('node:http');
const http = require('node:http');
const {configuration} = require('./lib/config');
const {createRepository} = require('./lib/repository');
const {createSessionService} = require('./lib/sessions');
@@ -33,7 +33,8 @@ async function createApplication(options = {}) {
if (require.main === module) {
require('dotenv').config();
createApplication().then(async application => {
const address = await application.listen();
let address;
try {address = await application.listen();} catch (error) {await application.close(); throw error;}
console.log(`Server listening at http://${address.address}:${address.port}`);
for (const signal of ['SIGINT', 'SIGTERM']) process.once(signal, () => application.close().catch(error => {console.error(error); process.exitCode = 1;}));
}).catch(error => {console.error(error.message); process.exitCode = 1;});