mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-30 20:41:33 +08: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)
 | ||||
| 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 sqlInit from "./services/sql_init.js"; | ||||
| require('./becca/entity_constructor'); | ||||
| await import("./becca/entity_constructor"); | ||||
| 
 | ||||
| sqlInit.dbReady.then(async () => { | ||||
|     try { | ||||
|  | ||||
							
								
								
									
										26
									
								
								src/app.ts
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								src/app.ts
									
									
									
									
									
								
							| @ -6,9 +6,13 @@ import helmet from "helmet"; | ||||
| import compression from "compression"; | ||||
| import sessionParser from "./routes/session_parser.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'); | ||||
| require('./becca/becca_loader'); | ||||
| await import('./services/handlers'); | ||||
| await import('./becca/becca_loader'); | ||||
| 
 | ||||
| const app = express(); | ||||
| 
 | ||||
| @ -37,24 +41,24 @@ app.use(`/robots.txt`, express.static(path.join(__dirname, 'public/robots.txt')) | ||||
| app.use(sessionParser); | ||||
| app.use(favicon(`${__dirname}/../images/app-icons/win/icon.ico`)); | ||||
| 
 | ||||
| require('./routes/assets').register(app); | ||||
| require('./routes/routes').register(app); | ||||
| require('./routes/custom').register(app); | ||||
| require('./routes/error_handlers').register(app); | ||||
| assets.register(app); | ||||
| routes.register(app); | ||||
| custom.register(app); | ||||
| error_handlers.register(app); | ||||
| 
 | ||||
| // triggers sync timer
 | ||||
| require('./services/sync'); | ||||
| await import("./services/sync"); | ||||
| 
 | ||||
| // triggers backup timer
 | ||||
| require('./services/backup'); | ||||
| await import('./services/backup'); | ||||
| 
 | ||||
| // trigger consistency checks timer
 | ||||
| require('./services/consistency_checks'); | ||||
| await import('./services/consistency_checks'); | ||||
| 
 | ||||
| require('./services/scheduler'); | ||||
| await import('./services/scheduler'); | ||||
| 
 | ||||
| if (utils.isElectron()) { | ||||
|     require('@electron/remote/main').initialize(); | ||||
|     (await import('@electron/remote/main')).initialize(); | ||||
| } | ||||
| 
 | ||||
| export default app; | ||||
|  | ||||
| @ -47,11 +47,7 @@ abstract class AbstractBeccaEntity<T extends AbstractBeccaEntity<T>> { | ||||
|     } | ||||
| 
 | ||||
|     protected get becca(): Becca { | ||||
|         if (!becca) { | ||||
|             becca = require('../becca'); | ||||
|         } | ||||
| 
 | ||||
|         return becca as Becca; | ||||
|         return becca; | ||||
|     } | ||||
| 
 | ||||
|     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(); | ||||
| 
 | ||||
| function startTrilium() { | ||||
| async function startTrilium() { | ||||
|     /** | ||||
|      * 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 | ||||
| @ -54,12 +54,12 @@ function startTrilium() { | ||||
|      * to do a complex evaluation. | ||||
|      */ | ||||
|     if (utils.isElectron()) { | ||||
|         require('electron').app.requestSingleInstanceLock(); | ||||
|         (await import('electron')).app.requestSingleInstanceLock(); | ||||
|     } | ||||
| 
 | ||||
|     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
 | ||||
|         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.
 | ||||
| 
 | ||||
|     if (utils.isElectron()) { | ||||
|         const electronRouting = require('./routes/electron'); | ||||
|         electronRouting(app); | ||||
|         const electronRouting = await import('./routes/electron'); | ||||
|         electronRouting.default(app); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran