@node-red/editor-api 3.1.0-beta.1 → 3.1.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/admin/index.js +2 -13
- package/lib/editor/index.js +4 -3
- package/lib/editor/projects.js +4 -3
- package/lib/editor/settings.js +2 -2
- package/lib/editor/sshkeys.js +4 -2
- package/lib/editor/theme.js +14 -4
- package/lib/index.js +5 -13
- package/lib/util.js +14 -3
- package/package.json +4 -4
package/lib/admin/index.js
CHANGED
|
@@ -14,8 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
**/
|
|
16
16
|
|
|
17
|
-
var express = require("express");
|
|
18
|
-
|
|
19
17
|
var nodes = require("./nodes");
|
|
20
18
|
var flows = require("./flows");
|
|
21
19
|
var flow = require("./flow");
|
|
@@ -37,18 +35,9 @@ module.exports = {
|
|
|
37
35
|
plugins.init(runtimeAPI);
|
|
38
36
|
diagnostics.init(settings, runtimeAPI);
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var adminApp = express();
|
|
43
|
-
|
|
44
|
-
var defaultServerSettings = {
|
|
45
|
-
"x-powered-by": false
|
|
46
|
-
}
|
|
47
|
-
var serverSettings = Object.assign({},defaultServerSettings,settings.httpServerOptions||{});
|
|
48
|
-
for (var eOption in serverSettings) {
|
|
49
|
-
adminApp.set(eOption, serverSettings[eOption]);
|
|
50
|
-
}
|
|
38
|
+
const needsPermission = auth.needsPermission;
|
|
51
39
|
|
|
40
|
+
const adminApp = apiUtil.createExpressApp(settings)
|
|
52
41
|
|
|
53
42
|
// Flows
|
|
54
43
|
adminApp.get("/flows",needsPermission("flows.read"),flows.get,apiUtil.errorHandler);
|
package/lib/editor/index.js
CHANGED
|
@@ -46,14 +46,15 @@ module.exports = {
|
|
|
46
46
|
runtimeAPI = _runtimeAPI;
|
|
47
47
|
needsPermission = auth.needsPermission;
|
|
48
48
|
if (!settings.disableEditor) {
|
|
49
|
-
info.init(runtimeAPI);
|
|
49
|
+
info.init(settings, runtimeAPI);
|
|
50
50
|
comms.init(server,settings,runtimeAPI);
|
|
51
51
|
|
|
52
52
|
var ui = require("./ui");
|
|
53
53
|
|
|
54
54
|
ui.init(runtimeAPI);
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
const editorApp = apiUtil.createExpressApp(settings)
|
|
57
|
+
|
|
57
58
|
if (settings.requireHttps === true) {
|
|
58
59
|
editorApp.enable('trust proxy');
|
|
59
60
|
editorApp.use(function (req, res, next) {
|
|
@@ -86,7 +87,7 @@ module.exports = {
|
|
|
86
87
|
|
|
87
88
|
//Projects
|
|
88
89
|
var projects = require("./projects");
|
|
89
|
-
projects.init(runtimeAPI);
|
|
90
|
+
projects.init(settings, runtimeAPI);
|
|
90
91
|
editorApp.use("/projects",projects.app());
|
|
91
92
|
|
|
92
93
|
// Locales
|
package/lib/editor/projects.js
CHANGED
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
**/
|
|
16
16
|
|
|
17
|
-
var express = require("express");
|
|
18
17
|
var apiUtils = require("../util");
|
|
19
18
|
|
|
19
|
+
var settings;
|
|
20
20
|
var runtimeAPI;
|
|
21
21
|
var needsPermission = require("../auth").needsPermission;
|
|
22
22
|
|
|
@@ -77,11 +77,12 @@ function getProjectRemotes(req,res) {
|
|
|
77
77
|
})
|
|
78
78
|
}
|
|
79
79
|
module.exports = {
|
|
80
|
-
init: function(_runtimeAPI) {
|
|
80
|
+
init: function(_settings, _runtimeAPI) {
|
|
81
|
+
settings = _settings;
|
|
81
82
|
runtimeAPI = _runtimeAPI;
|
|
82
83
|
},
|
|
83
84
|
app: function() {
|
|
84
|
-
var app =
|
|
85
|
+
var app = apiUtils.createExpressApp(settings)
|
|
85
86
|
|
|
86
87
|
app.use(function(req,res,next) {
|
|
87
88
|
runtimeAPI.projects.available().then(function(available) {
|
package/lib/editor/settings.js
CHANGED
|
@@ -18,9 +18,9 @@ var runtimeAPI;
|
|
|
18
18
|
var sshkeys = require("./sshkeys");
|
|
19
19
|
|
|
20
20
|
module.exports = {
|
|
21
|
-
init: function(_runtimeAPI) {
|
|
21
|
+
init: function(settings, _runtimeAPI) {
|
|
22
22
|
runtimeAPI = _runtimeAPI;
|
|
23
|
-
sshkeys.init(runtimeAPI);
|
|
23
|
+
sshkeys.init(settings, runtimeAPI);
|
|
24
24
|
},
|
|
25
25
|
userSettings: function(req, res) {
|
|
26
26
|
var opts = {
|
package/lib/editor/sshkeys.js
CHANGED
|
@@ -17,13 +17,15 @@
|
|
|
17
17
|
var apiUtils = require("../util");
|
|
18
18
|
var express = require("express");
|
|
19
19
|
var runtimeAPI;
|
|
20
|
+
var settings;
|
|
20
21
|
|
|
21
22
|
module.exports = {
|
|
22
|
-
init: function(_runtimeAPI) {
|
|
23
|
+
init: function(_settings, _runtimeAPI) {
|
|
23
24
|
runtimeAPI = _runtimeAPI;
|
|
25
|
+
settings = _settings;
|
|
24
26
|
},
|
|
25
27
|
app: function() {
|
|
26
|
-
|
|
28
|
+
const app = apiUtils.createExpressApp(settings);
|
|
27
29
|
|
|
28
30
|
// List all SSH keys
|
|
29
31
|
app.get("/", function(req,res) {
|
package/lib/editor/theme.js
CHANGED
|
@@ -19,6 +19,7 @@ var util = require("util");
|
|
|
19
19
|
var path = require("path");
|
|
20
20
|
var fs = require("fs");
|
|
21
21
|
var clone = require("clone");
|
|
22
|
+
const apiUtil = require("../util")
|
|
22
23
|
|
|
23
24
|
var defaultContext = {
|
|
24
25
|
page: {
|
|
@@ -27,8 +28,7 @@ var defaultContext = {
|
|
|
27
28
|
tabicon: {
|
|
28
29
|
icon: "red/images/node-red-icon-black.svg",
|
|
29
30
|
colour: "#8f0000"
|
|
30
|
-
}
|
|
31
|
-
version: require(path.join(__dirname,"../../package.json")).version
|
|
31
|
+
}
|
|
32
32
|
},
|
|
33
33
|
header: {
|
|
34
34
|
title: "Node-RED",
|
|
@@ -40,6 +40,7 @@ var defaultContext = {
|
|
|
40
40
|
vendorMonaco: ""
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
+
var settings;
|
|
43
44
|
|
|
44
45
|
var theme = null;
|
|
45
46
|
var themeContext = clone(defaultContext);
|
|
@@ -92,7 +93,8 @@ function serveFilesFromTheme(themeValue, themeApp, directory, baseDirectory) {
|
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
module.exports = {
|
|
95
|
-
init: function(
|
|
96
|
+
init: function(_settings, _runtimeAPI) {
|
|
97
|
+
settings = _settings;
|
|
96
98
|
runtimeAPI = _runtimeAPI;
|
|
97
99
|
themeContext = clone(defaultContext);
|
|
98
100
|
if (process.env.NODE_ENV == "development") {
|
|
@@ -113,7 +115,15 @@ module.exports = {
|
|
|
113
115
|
var url;
|
|
114
116
|
themeSettings = {};
|
|
115
117
|
|
|
116
|
-
themeApp =
|
|
118
|
+
themeApp = apiUtil.createExpressApp(settings);
|
|
119
|
+
|
|
120
|
+
const defaultServerSettings = {
|
|
121
|
+
"x-powered-by": false
|
|
122
|
+
}
|
|
123
|
+
const serverSettings = Object.assign({},defaultServerSettings,settings.httpServerOptions||{});
|
|
124
|
+
for (const eOption in serverSettings) {
|
|
125
|
+
themeApp.set(eOption, serverSettings[eOption]);
|
|
126
|
+
}
|
|
117
127
|
|
|
118
128
|
if (theme.page) {
|
|
119
129
|
|
package/lib/index.js
CHANGED
|
@@ -37,7 +37,6 @@ var adminApp;
|
|
|
37
37
|
var server;
|
|
38
38
|
var editor;
|
|
39
39
|
|
|
40
|
-
|
|
41
40
|
/**
|
|
42
41
|
* Initialise the module.
|
|
43
42
|
* @param {Object} settings The runtime settings
|
|
@@ -49,7 +48,7 @@ var editor;
|
|
|
49
48
|
function init(settings,_server,storage,runtimeAPI) {
|
|
50
49
|
server = _server;
|
|
51
50
|
if (settings.httpAdminRoot !== false) {
|
|
52
|
-
adminApp =
|
|
51
|
+
adminApp = apiUtil.createExpressApp(settings);
|
|
53
52
|
|
|
54
53
|
var cors = require('cors');
|
|
55
54
|
var corsHandler = cors({
|
|
@@ -64,14 +63,6 @@ function init(settings,_server,storage,runtimeAPI) {
|
|
|
64
63
|
}
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
var defaultServerSettings = {
|
|
68
|
-
"x-powered-by": false
|
|
69
|
-
}
|
|
70
|
-
var serverSettings = Object.assign({},defaultServerSettings,settings.httpServerOptions||{});
|
|
71
|
-
for (var eOption in serverSettings) {
|
|
72
|
-
adminApp.set(eOption, serverSettings[eOption]);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
66
|
auth.init(settings,storage);
|
|
76
67
|
|
|
77
68
|
var maxApiRequestSize = settings.apiMaxLength || '5mb';
|
|
@@ -136,10 +127,11 @@ async function stop() {
|
|
|
136
127
|
editor.stop();
|
|
137
128
|
}
|
|
138
129
|
}
|
|
130
|
+
|
|
139
131
|
module.exports = {
|
|
140
|
-
init
|
|
141
|
-
start
|
|
142
|
-
stop
|
|
132
|
+
init,
|
|
133
|
+
start,
|
|
134
|
+
stop,
|
|
143
135
|
|
|
144
136
|
/**
|
|
145
137
|
* @memberof @node-red/editor-api
|
package/lib/util.js
CHANGED
|
@@ -14,10 +14,9 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
**/
|
|
16
16
|
|
|
17
|
+
const express = require("express");
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
var i18n = require("@node-red/util").i18n; // TODO: separate module
|
|
20
|
-
|
|
19
|
+
const { log, i18n } = require("@node-red/util");
|
|
21
20
|
|
|
22
21
|
module.exports = {
|
|
23
22
|
errorHandler: function(err,req,res,next) {
|
|
@@ -64,5 +63,17 @@ module.exports = {
|
|
|
64
63
|
path: req.path,
|
|
65
64
|
ip: (req.headers && req.headers['x-forwarded-for']) || (req.connection && req.connection.remoteAddress) || undefined
|
|
66
65
|
}
|
|
66
|
+
},
|
|
67
|
+
createExpressApp: function(settings) {
|
|
68
|
+
const app = express();
|
|
69
|
+
|
|
70
|
+
const defaultServerSettings = {
|
|
71
|
+
"x-powered-by": false
|
|
72
|
+
}
|
|
73
|
+
const serverSettings = Object.assign({},defaultServerSettings,settings.httpServerOptions||{});
|
|
74
|
+
for (let eOption in serverSettings) {
|
|
75
|
+
app.set(eOption, serverSettings[eOption]);
|
|
76
|
+
}
|
|
77
|
+
return app
|
|
67
78
|
}
|
|
68
79
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-red/editor-api",
|
|
3
|
-
"version": "3.1.0-beta.
|
|
3
|
+
"version": "3.1.0-beta.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
}
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@node-red/util": "3.1.0-beta.
|
|
20
|
-
"@node-red/editor-client": "3.1.0-beta.
|
|
19
|
+
"@node-red/util": "3.1.0-beta.3",
|
|
20
|
+
"@node-red/editor-client": "3.1.0-beta.3",
|
|
21
21
|
"bcryptjs": "2.4.3",
|
|
22
|
-
"body-parser": "1.20.
|
|
22
|
+
"body-parser": "1.20.2",
|
|
23
23
|
"clone": "2.1.2",
|
|
24
24
|
"cors": "2.8.5",
|
|
25
25
|
"express-session": "1.17.3",
|