server-ts: Address self-review

This commit is contained in:
Elian Doran 2024-04-02 23:55:02 +03:00
parent d4c8d24d50
commit 99d50957dd
No known key found for this signature in database
4 changed files with 24 additions and 24 deletions

View File

@ -10,7 +10,7 @@ if (config.Network.https) {
process.exit(0); process.exit(0);
} }
const port = require('./src/services/port.ts'); const port = require('./src/services/port');
const host = require('./src/services/host'); const host = require('./src/services/host');
const options = { timeout: 2000 }; const options = { timeout: 2000 };

View File

@ -20,6 +20,6 @@ export interface EntityRow {
} }
export interface EntityChangeRecord { export interface EntityChangeRecord {
entityChange: EntityChange; entityChange: EntityChange;
entity?: EntityRow; entity?: EntityRow;
} }

View File

@ -25,7 +25,7 @@ class OrderByAndLimitExp extends Expression {
constructor(orderDefinitions: Pick<OrderDefinition, "direction" | "valueExtractor">[], limit?: number) { constructor(orderDefinitions: Pick<OrderDefinition, "direction" | "valueExtractor">[], limit?: number) {
super(); super();
this.orderDefinitions = orderDefinitions as unknown as OrderDefinition[]; this.orderDefinitions = orderDefinitions as OrderDefinition[];
for (const od of this.orderDefinitions) { for (const od of this.orderDefinitions) {
od.smaller = od.direction === "asc" ? -1 : 1; od.smaller = od.direction === "asc" ? -1 : 1;

View File

@ -45,7 +45,7 @@ function startTrilium() {
* instead of the new one. This is complicated by the fact that it is possible to run multiple instances of Trilium * instead of the new one. This is complicated by the fact that it is possible to run multiple instances of Trilium
* if port and data dir are configured separately. This complication is the source of the following weird usage. * if port and data dir are configured separately. This complication is the source of the following weird usage.
* *
* The line below makes sure that the "second-instance" (process in window) is fired. Normally it returns a boolean * The line below makes sure that the "second-instance" (process in window.ts) is fired. Normally it returns a boolean
* indicating whether another instance is running or not, but we ignore that and kill the app only based on the port conflict. * indicating whether another instance is running or not, but we ignore that and kill the app only based on the port conflict.
* *
* A bit weird is that "second-instance" is triggered also on the valid usecases (different port/data dir) and * A bit weird is that "second-instance" is triggered also on the valid usecases (different port/data dir) and
@ -126,26 +126,26 @@ function startHttpServer() {
} }
httpServer.on('error', error => { httpServer.on('error', error => {
if (!listenOnTcp || error.syscall !== 'listen') { if (!listenOnTcp || error.syscall !== 'listen') {
throw error; throw error;
}
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(`Port ${port} requires elevated privileges. It's recommended to use port above 1024.`);
process.exit(1);
break;
case 'EADDRINUSE':
console.error(`Port ${port} is already in use. Most likely, another Trilium process is already running. You might try to find it, kill it, and try again.`);
process.exit(1);
break;
default:
throw error;
}
} }
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(`Port ${port} requires elevated privileges. It's recommended to use port above 1024.`);
process.exit(1);
break;
case 'EADDRINUSE':
console.error(`Port ${port} is already in use. Most likely, another Trilium process is already running. You might try to find it, kill it, and try again.`);
process.exit(1);
break;
default:
throw error;
}
}
) )
httpServer.on('listening', () => { httpServer.on('listening', () => {