|
@@ -35,6 +35,8 @@ function Crowi(rootdir) {
|
|
|
this.tmpDir = path.join(this.rootDir, 'tmp') + sep;
|
|
this.tmpDir = path.join(this.rootDir, 'tmp') + sep;
|
|
|
this.cacheDir = path.join(this.tmpDir, 'cache');
|
|
this.cacheDir = path.join(this.tmpDir, 'cache');
|
|
|
|
|
|
|
|
|
|
+ this.express = null;
|
|
|
|
|
+
|
|
|
this.config = {};
|
|
this.config = {};
|
|
|
this.configManager = null;
|
|
this.configManager = null;
|
|
|
this.mailService = null;
|
|
this.mailService = null;
|
|
@@ -378,7 +380,9 @@ Crowi.prototype.start = async function() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
await this.init();
|
|
await this.init();
|
|
|
- const express = await this.buildServer();
|
|
|
|
|
|
|
+ await this.buildServer();
|
|
|
|
|
+
|
|
|
|
|
+ const { express } = this;
|
|
|
|
|
|
|
|
// setup plugins
|
|
// setup plugins
|
|
|
this.pluginService = new PluginService(this, express);
|
|
this.pluginService = new PluginService(this, express);
|
|
@@ -401,14 +405,14 @@ Crowi.prototype.start = async function() {
|
|
|
this.io = io;
|
|
this.io = io;
|
|
|
|
|
|
|
|
// setup Express Routes
|
|
// setup Express Routes
|
|
|
- this.setupRoutesAtLast(express);
|
|
|
|
|
|
|
+ this.setupRoutesAtLast();
|
|
|
|
|
|
|
|
return serverListening;
|
|
return serverListening;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-Crowi.prototype.buildServer = function() {
|
|
|
|
|
- const express = require('express')();
|
|
|
|
|
|
|
+Crowi.prototype.buildServer = async function() {
|
|
|
const env = this.node_env;
|
|
const env = this.node_env;
|
|
|
|
|
+ const express = require('express')();
|
|
|
|
|
|
|
|
require('./express-init')(this, express);
|
|
require('./express-init')(this, express);
|
|
|
|
|
|
|
@@ -427,15 +431,20 @@ Crowi.prototype.buildServer = function() {
|
|
|
express.use(morgan('dev'));
|
|
express.use(morgan('dev'));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return Promise.resolve(express);
|
|
|
|
|
|
|
+ this.express = express;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* setup Express Routes
|
|
* setup Express Routes
|
|
|
* !! this must be at last because it includes '/*' route !!
|
|
* !! this must be at last because it includes '/*' route !!
|
|
|
*/
|
|
*/
|
|
|
-Crowi.prototype.setupRoutesAtLast = function(app) {
|
|
|
|
|
- require('../routes')(this, app);
|
|
|
|
|
|
|
+Crowi.prototype.setupRoutesAtLast = function() {
|
|
|
|
|
+ require('../routes')(this, this.express);
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+Crowi.prototype.setupAfterInstall = function() {
|
|
|
|
|
+ this.pluginService.autoDetectAndLoadPlugins();
|
|
|
|
|
+ this.setupRoutesAtLast();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -496,7 +505,7 @@ Crowi.prototype.setUpAcl = async function() {
|
|
|
Crowi.prototype.setUpCustomize = async function() {
|
|
Crowi.prototype.setUpCustomize = async function() {
|
|
|
const CustomizeService = require('../service/customize');
|
|
const CustomizeService = require('../service/customize');
|
|
|
if (this.customizeService == null) {
|
|
if (this.customizeService == null) {
|
|
|
- this.customizeService = new CustomizeService(this.configManager, this.appService, this.xssService, this.configPubsub);
|
|
|
|
|
|
|
+ this.customizeService = new CustomizeService(this);
|
|
|
this.customizeService.initCustomCss();
|
|
this.customizeService.initCustomCss();
|
|
|
this.customizeService.initCustomTitle();
|
|
this.customizeService.initCustomTitle();
|
|
|
|
|
|
|
@@ -513,7 +522,13 @@ Crowi.prototype.setUpCustomize = async function() {
|
|
|
Crowi.prototype.setUpApp = async function() {
|
|
Crowi.prototype.setUpApp = async function() {
|
|
|
const AppService = require('../service/app');
|
|
const AppService = require('../service/app');
|
|
|
if (this.appService == null) {
|
|
if (this.appService == null) {
|
|
|
- this.appService = new AppService(this.configManager);
|
|
|
|
|
|
|
+ this.appService = new AppService(this);
|
|
|
|
|
+
|
|
|
|
|
+ // add as a message handler
|
|
|
|
|
+ const isInstalled = this.configManager.getConfig('crowi', 'app:installed');
|
|
|
|
|
+ if (this.configPubsub != null && !isInstalled) {
|
|
|
|
|
+ this.configPubsub.addMessageHandler(this.appService);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|