cherry-pick features/react-routes

This commit is contained in:
Iuri Matias 2018-07-13 10:50:57 +03:00 committed by Pascal Precht
parent 4e30ddeb1b
commit 50740211da
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
3 changed files with 17 additions and 7 deletions

View File

@ -387,7 +387,8 @@ Config.prototype.loadWebServerConfigFile = function() {
"enabled": true,
"host": defaultHost,
"openBrowser": true,
"port": 8000
"port": 8000,
"enableCatchAll": true
};
let configFilePath = this._getFileOrOject(this.configDir, 'webserver', 'webserver');

View File

@ -23,6 +23,7 @@ class WebServer {
this.host = this.webServerConfig.host;
this.port = parseInt(this.webServerConfig.port, 10);
this.enableCatchAll = this.webServerConfig.enableCatchAll === true;
this.events.emit("status", __("Starting Server"));

View File

@ -77,12 +77,13 @@ class Server {
});
});
let apiCalls = self.plugins.getPluginsProperty("apiCalls", "apiCalls");
console.dir(apiCalls);
for (let apiCall of apiCalls) {
console.dir("adding " + apiCall.method + " " + apiCall.endpoint);
app[apiCall.method].apply(app, [apiCall.endpoint, apiCall.cb]);
}
if (self.plugins) {
let apiCalls = self.plugins.getPluginsProperty("apiCalls", "apiCalls");
for (let apiCall of apiCalls) {
console.dir("adding " + apiCall.method + " " + apiCall.endpoint);
app[apiCall.method].apply(app, [apiCall.endpoint, apiCall.cb]);
}
}
this.app.ws('/', function(ws, _req) {
self.events.on('outputDone', () => {
@ -97,6 +98,13 @@ class Server {
});
});
if (this.enableCatchAll === true) {
app.get('/*', function (req, res) {
self.logger.trace('webserver> GET ' + req.path);
res.sendFile(path.join(fs.dappPath(self.dist, 'index.html')));
}
}
async.waterfall([
function createPlaceholderPage(next) {
if (!self.isFirstStart) {