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;});
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ function createLobbyService(repository, config) {
|
||||
const membershipMutation = ['lobby:create', 'lobby:join', 'lobby:leave'].includes(message.type);
|
||||
return queue.run([...(membershipMutation ? ['membership'] : []), ...(username ? [`account:${username}`] : []),
|
||||
...(message.lobbyId ? [`lobby:${message.lobbyId}`] : [])], async () => {
|
||||
const id = `${username || 'system'}:${message.requestId}`;
|
||||
const id = `${username ? `user:${username}` : 'system'}:${message.requestId}`;
|
||||
const fingerprint = hash(JSON.stringify(canonical(message)));
|
||||
const prior = await repository.command(id);
|
||||
if (prior) {
|
||||
|
||||
+2
-2
@@ -45,11 +45,11 @@ window.RealtimeClient = class extends EventTarget {
|
||||
}
|
||||
this.dispatchEvent(new CustomEvent('message', {detail: message}));
|
||||
});
|
||||
socket.addEventListener('error', () => this.status('Connection interrupted. Reconnecting…'));
|
||||
socket.addEventListener('error', () => this.status('Connection interrupted. Reconnecting...'));
|
||||
socket.addEventListener('close', async event => {
|
||||
clearTimeout(timeout); this.ready = false;
|
||||
if (this.stopped) return;
|
||||
this.status('Connection interrupted. Reconnecting…');
|
||||
this.status('Connection interrupted. Reconnecting...');
|
||||
if (event.code === 1008 && /Session/.test(event.reason)) {
|
||||
this.close(); localStorage.removeItem('activeLobbyId'); location.assign('/login'); return;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
|
||||
if (winner) {
|
||||
const heading = document.createElement("h2");
|
||||
heading.textContent = `Winner: ${winner}`;
|
||||
heading.textContent = `Payout recipients: ${winner}`;
|
||||
showdownPanel.appendChild(heading);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user