try to fix this spaghetti of a code
This commit is contained in:
+3
-2
@@ -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;});
|
||||
|
||||
Reference in New Issue
Block a user