mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Separate out httpAdmin and httpNode
This commit is contained in:
@@ -42,7 +42,9 @@ var RED = {
|
||||
events: events
|
||||
};
|
||||
|
||||
RED.__defineGetter__("app", function() { return server.app });
|
||||
RED.__defineGetter__("app", function() { console.log("Deprecated use of RED.app - use RED.httpAdmin instead"); return server.app });
|
||||
RED.__defineGetter__("httpAdmin", function() { return server.app });
|
||||
RED.__defineGetter__("httpNode", function() { return server.nodeApp });
|
||||
RED.__defineGetter__("server", function() { return server.server });
|
||||
RED.__defineGetter__("settings", function() { return settings });
|
||||
|
||||
|
@@ -14,11 +14,13 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var express = require('express');
|
||||
var util = require('util');
|
||||
var createUI = require("./ui");
|
||||
var redNodes = require("./nodes");
|
||||
|
||||
var app = null;
|
||||
var nodeApp = null;
|
||||
var server = null;
|
||||
var settings = null;
|
||||
var storage = null;
|
||||
@@ -28,6 +30,7 @@ function createServer(_server,_settings) {
|
||||
settings = _settings;
|
||||
storage = require("./storage");
|
||||
app = createUI(settings);
|
||||
nodeApp = express();
|
||||
|
||||
flowfile = settings.flowFile || 'flows_'+require('os').hostname()+'.json';
|
||||
|
||||
@@ -103,4 +106,5 @@ module.exports = {
|
||||
}
|
||||
|
||||
module.exports.__defineGetter__("app", function() { return app });
|
||||
module.exports.__defineGetter__("nodeApp", function() { return nodeApp });
|
||||
module.exports.__defineGetter__("server", function() { return server });
|
||||
|
30
red/ui.js
30
red/ui.js
@@ -34,24 +34,30 @@ function setupUI(settings) {
|
||||
// Need to ensure the url ends with a '/' so the static serving works
|
||||
// with relative paths
|
||||
app.get("/",function(req,res) {
|
||||
if (req.originalUrl.slice(-1) != "/") {
|
||||
res.redirect(req.originalUrl+"/");
|
||||
} else {
|
||||
req.next();
|
||||
}
|
||||
if (req.originalUrl.slice(-1) != "/") {
|
||||
res.redirect(req.originalUrl+"/");
|
||||
} else {
|
||||
req.next();
|
||||
}
|
||||
});
|
||||
|
||||
app.get("/icons/:icon",function(req,res) {
|
||||
for (var p in icon_paths) {
|
||||
if (fs.existsSync(icon_paths[p]+'/'+req.params.icon)) {
|
||||
res.sendfile(icon_paths[p]+'/'+req.params.icon);
|
||||
return;
|
||||
}
|
||||
for (var p in icon_paths) {
|
||||
if (fs.existsSync(icon_paths[p]+'/'+req.params.icon)) {
|
||||
res.sendfile(icon_paths[p]+'/'+req.params.icon);
|
||||
return;
|
||||
}
|
||||
//TODO: create a default icon
|
||||
res.sendfile(path.resolve(__dirname + '/../public/icons/arrow-in.png'));
|
||||
}
|
||||
//TODO: create a default icon
|
||||
res.sendfile(path.resolve(__dirname + '/../public/icons/arrow-in.png'));
|
||||
});
|
||||
|
||||
app.get("/settings", function(req,res) {
|
||||
var safeSettings = {
|
||||
httpNodeRoot: settings.httpNodeRoot
|
||||
};
|
||||
res.json(safeSettings);
|
||||
});
|
||||
|
||||
app.use("/",express.static(__dirname + '/../public'));
|
||||
|
||||
|
Reference in New Issue
Block a user