mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
server-esm: Start with some fundamental imports
This commit is contained in:
parent
6de1291efa
commit
8a30663d1e
@ -62,4 +62,4 @@ electron.app.on("will-quit", () => {
|
|||||||
// this is to disable electron warning spam in the dev console (local development only)
|
// this is to disable electron warning spam in the dev console (local development only)
|
||||||
process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true";
|
process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true";
|
||||||
|
|
||||||
require('./src/www.js');
|
await import('./src/www.js');
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import anonymizationService from "./services/anonymization.js";
|
import anonymizationService from "./services/anonymization.js";
|
||||||
import sqlInit from "./services/sql_init.js";
|
import sqlInit from "./services/sql_init.js";
|
||||||
require('./becca/entity_constructor');
|
await import("./becca/entity_constructor");
|
||||||
|
|
||||||
sqlInit.dbReady.then(async () => {
|
sqlInit.dbReady.then(async () => {
|
||||||
try {
|
try {
|
||||||
|
26
src/app.ts
26
src/app.ts
@ -6,9 +6,13 @@ import helmet from "helmet";
|
|||||||
import compression from "compression";
|
import compression from "compression";
|
||||||
import sessionParser from "./routes/session_parser.js";
|
import sessionParser from "./routes/session_parser.js";
|
||||||
import utils from "./services/utils.js";
|
import utils from "./services/utils.js";
|
||||||
|
import assets from "./routes/assets.js";
|
||||||
|
import routes from "./routes/routes.js";
|
||||||
|
import custom from "./routes/custom.js";
|
||||||
|
import error_handlers from "./routes/error_handlers.js";
|
||||||
|
|
||||||
require('./services/handlers');
|
await import('./services/handlers');
|
||||||
require('./becca/becca_loader');
|
await import('./becca/becca_loader');
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
@ -37,24 +41,24 @@ app.use(`/robots.txt`, express.static(path.join(__dirname, 'public/robots.txt'))
|
|||||||
app.use(sessionParser);
|
app.use(sessionParser);
|
||||||
app.use(favicon(`${__dirname}/../images/app-icons/win/icon.ico`));
|
app.use(favicon(`${__dirname}/../images/app-icons/win/icon.ico`));
|
||||||
|
|
||||||
require('./routes/assets').register(app);
|
assets.register(app);
|
||||||
require('./routes/routes').register(app);
|
routes.register(app);
|
||||||
require('./routes/custom').register(app);
|
custom.register(app);
|
||||||
require('./routes/error_handlers').register(app);
|
error_handlers.register(app);
|
||||||
|
|
||||||
// triggers sync timer
|
// triggers sync timer
|
||||||
require('./services/sync');
|
await import("./services/sync");
|
||||||
|
|
||||||
// triggers backup timer
|
// triggers backup timer
|
||||||
require('./services/backup');
|
await import('./services/backup');
|
||||||
|
|
||||||
// trigger consistency checks timer
|
// trigger consistency checks timer
|
||||||
require('./services/consistency_checks');
|
await import('./services/consistency_checks');
|
||||||
|
|
||||||
require('./services/scheduler');
|
await import('./services/scheduler');
|
||||||
|
|
||||||
if (utils.isElectron()) {
|
if (utils.isElectron()) {
|
||||||
require('@electron/remote/main').initialize();
|
(await import('@electron/remote/main')).initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
@ -47,11 +47,7 @@ abstract class AbstractBeccaEntity<T extends AbstractBeccaEntity<T>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected get becca(): Becca {
|
protected get becca(): Becca {
|
||||||
if (!becca) {
|
return becca;
|
||||||
becca = require('../becca');
|
|
||||||
}
|
|
||||||
|
|
||||||
return becca as Becca;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected putEntityChange(isDeleted: boolean) {
|
protected putEntityChange(isDeleted: boolean) {
|
||||||
|
10
src/www.ts
10
src/www.ts
@ -39,7 +39,7 @@ if (!semver.satisfies(process.version, ">=10.5.0")) {
|
|||||||
|
|
||||||
startTrilium();
|
startTrilium();
|
||||||
|
|
||||||
function startTrilium() {
|
async function startTrilium() {
|
||||||
/**
|
/**
|
||||||
* The intended behavior is to detect when a second instance is running, in that case open the old instance
|
* The intended behavior is to detect when a second instance is running, in that case open the old instance
|
||||||
* 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
|
||||||
@ -54,12 +54,12 @@ function startTrilium() {
|
|||||||
* to do a complex evaluation.
|
* to do a complex evaluation.
|
||||||
*/
|
*/
|
||||||
if (utils.isElectron()) {
|
if (utils.isElectron()) {
|
||||||
require('electron').app.requestSingleInstanceLock();
|
(await import('electron')).app.requestSingleInstanceLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info(JSON.stringify(appInfo, null, 2));
|
log.info(JSON.stringify(appInfo, null, 2));
|
||||||
|
|
||||||
const cpuInfos = require('os').cpus();
|
const cpuInfos = (await import('os')).cpus();
|
||||||
if (cpuInfos && cpuInfos[0] !== undefined) { // https://github.com/zadam/trilium/pull/3957
|
if (cpuInfos && cpuInfos[0] !== undefined) { // https://github.com/zadam/trilium/pull/3957
|
||||||
log.info(`CPU model: ${cpuInfos[0].model}, logical cores: ${cpuInfos.length} freq: ${cpuInfos[0].speed} Mhz`); // for perf. issues it's good to know the rough configuration
|
log.info(`CPU model: ${cpuInfos[0].model}, logical cores: ${cpuInfos.length} freq: ${cpuInfos[0].speed} Mhz`); // for perf. issues it's good to know the rough configuration
|
||||||
}
|
}
|
||||||
@ -69,8 +69,8 @@ function startTrilium() {
|
|||||||
ws.init(httpServer, sessionParser as any); // TODO: Not sure why session parser is incompatible.
|
ws.init(httpServer, sessionParser as any); // TODO: Not sure why session parser is incompatible.
|
||||||
|
|
||||||
if (utils.isElectron()) {
|
if (utils.isElectron()) {
|
||||||
const electronRouting = require('./routes/electron');
|
const electronRouting = await import('./routes/electron');
|
||||||
electronRouting(app);
|
electronRouting.default(app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user