1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Initialise nodeApp regardless of httpAdmin setting

Closes #1096 #1095
This commit is contained in:
Nick O'Leary 2017-01-09 22:22:49 +00:00
parent f248699a30
commit 75855d5450
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
4 changed files with 13 additions and 10 deletions

View File

@ -39,7 +39,6 @@ var needsPermission = auth.needsPermission;
var i18n;
var log;
var adminApp;
var nodeApp;
var server;
var runtime;
@ -68,9 +67,6 @@ function init(_server,_runtime) {
var settings = runtime.settings;
i18n = runtime.i18n;
log = runtime.log;
if (settings.httpNodeRoot !== false) {
nodeApp = express();
}
if (settings.httpAdminRoot !== false) {
comms.init(server,runtime);
adminApp = express();
@ -192,6 +188,5 @@ module.exports = {
publish: comms.publish
},
get adminApp() { return adminApp; },
get nodeApp() { return nodeApp; },
get server() { return server; }
};

View File

@ -53,7 +53,7 @@ module.exports = {
userSettings.coreNodesDir = path.resolve(path.join(__dirname,"..","nodes"));
}
if (userSettings.httpAdminRoot !== false || userSettings.httpNodeRoot !== false) {
if (userSettings.httpAdminRoot !== false) {
runtime.init(userSettings,api);
api.init(httpServer,runtime);
apiEnabled = true;
@ -62,7 +62,7 @@ module.exports = {
apiEnabled = false;
}
adminApp = runtime.adminApi.adminApp;
nodeApp = runtime.adminApi.nodeApp;
nodeApp = runtime.nodeApp;
server = runtime.adminApi.server;
return;
},

View File

@ -22,6 +22,8 @@ var log = require("./log");
var i18n = require("./i18n");
var events = require("./events");
var settings = require("./settings");
var express = require("express");
var path = require('path');
var fs = require("fs");
var os = require("os");
@ -47,19 +49,22 @@ var adminApi = {
publish: function() {}
},
adminApp: stubbedExpressApp,
nodeApp: stubbedExpressApp,
server: {}
}
var nodeApp;
function init(userSettings,_adminApi) {
userSettings.version = getVersion();
log.init(userSettings);
settings.init(userSettings);
nodeApp = express();
if (_adminApi) {
adminApi = _adminApi;
}
redNodes.init(runtime);
}
var version;
@ -189,6 +194,7 @@ var runtime = module.exports = {
nodes: redNodes,
util: require("./util"),
get adminApi() { return adminApi },
get nodeApp() { return nodeApp },
isStarted: function() {
return started;
}

View File

@ -83,9 +83,11 @@ function createNodeApi(node) {
red.library = runtime.adminApi.library;
red.auth = runtime.adminApi.auth;
red.httpAdmin = runtime.adminApi.adminApp;
red.httpNode = runtime.adminApi.nodeApp;
red.httpNode = runtime.nodeApp;
red.server = runtime.adminApi.server;
} else {
//TODO: runtime.adminApi is always stubbed if not enabled, so this block
// is unused - but may be needed for the unit tests
red.comms = {
publish: function() {}
};