mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
NLS /red/nodes
NLS other js files under /red NLS /red files (changed based on Nick's review)
This commit is contained in:
parent
203bc41b06
commit
2563649b3e
@ -54,6 +54,11 @@
|
||||
"error-send": "Communication send error: __message__"
|
||||
},
|
||||
|
||||
"settings": {
|
||||
"not-available": "Settings not available",
|
||||
"property-read-only": "Property '__prop__' is read-only"
|
||||
},
|
||||
|
||||
"nodes": {
|
||||
"credentials": {
|
||||
"error":"Error loading credentials: __message__",
|
||||
@ -77,15 +82,39 @@
|
||||
"stopped": "Stopped",
|
||||
"missing-types": "Waiting for missing types to be registered:"
|
||||
|
||||
},
|
||||
"flow": {
|
||||
"unknown-type": "Unknown type: __type__",
|
||||
"missing-types": "missing types"
|
||||
},
|
||||
"index": {
|
||||
"unrecognised-id": "Unrecognised id: __id__",
|
||||
"type-in-use": "Type in use: __msg__",
|
||||
"unrecognised-module": "Unrecognised module: __module__"
|
||||
},
|
||||
"registry": {
|
||||
"localfilesystem": {
|
||||
"module-not-found": "Cannot find module '__module__'"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"storage": {
|
||||
"index": {
|
||||
"forbidden-flow-name": "forbidden flow name"
|
||||
},
|
||||
"localfilesystem": {
|
||||
"user-dir": "User directory : __path__",
|
||||
"flows-file": "Flows file : __path__",
|
||||
"create": "Creating new flow file"
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
"httpadminauth-deprecated": "use of httpAdminAuth is deprecated. Use adminAuth instead",
|
||||
"unable-to-listen": "Unable to listen on __listenpath__",
|
||||
"port-in-use": "Error: port in use",
|
||||
"uncaught-exception": "Uncaught Exception:",
|
||||
"admin-ui-disabled": "Admin UI disabled",
|
||||
"server-now-running": "Server now running at __listenpath__",
|
||||
"failed-to-start-server": "Failed to start server:"
|
||||
}
|
||||
|
14
red.js
14
red.js
@ -166,7 +166,7 @@ try {
|
||||
}
|
||||
|
||||
if (settings.httpAdminRoot !== false && settings.httpAdminAuth) {
|
||||
RED.log.warn("use of httpAdminAuth is deprecated. Use adminAuth instead");
|
||||
RED.log.warn(log._("httpadminauth-deprecated"));
|
||||
app.use(settings.httpAdminRoot,
|
||||
express.basicAuth(function(user, pass) {
|
||||
return user === settings.httpAdminAuth.user && crypto.createHash('md5').update(pass,'utf8').digest('hex') === settings.httpAdminAuth.pass;
|
||||
@ -216,10 +216,10 @@ RED.start().then(function() {
|
||||
if (settings.httpAdminRoot !== false || settings.httpNodeRoot !== false || settings.httpStatic) {
|
||||
server.on('error', function(err) {
|
||||
if (err.errno === "EADDRINUSE") {
|
||||
RED.log.error('Unable to listen on '+getListenPath());
|
||||
RED.log.error('Error: port in use');
|
||||
RED.log.error(log._("unable-to-listen", {listenpath:getListenPath()}));
|
||||
RED.log.error(log._("port-in-use"));
|
||||
} else {
|
||||
RED.log.error('Uncaught Exception:');
|
||||
RED.log.error(log._("uncaught-exception"));
|
||||
if (err.stack) {
|
||||
RED.log.error(err.stack);
|
||||
} else {
|
||||
@ -230,16 +230,16 @@ RED.start().then(function() {
|
||||
});
|
||||
server.listen(settings.uiPort,settings.uiHost,function() {
|
||||
if (settings.httpAdminRoot === false) {
|
||||
RED.log.info('Admin UI disabled');
|
||||
RED.log.info(log._("admin-ui-disabled"));
|
||||
}
|
||||
process.title = 'node-red';
|
||||
RED.log.info('Server now running at '+getListenPath());
|
||||
RED.log.info(log._("server-now-running", {listenpath:getListenPath()}));
|
||||
});
|
||||
} else {
|
||||
util.log('[red] Running in headless mode');
|
||||
}
|
||||
}).otherwise(function(err) {
|
||||
RED.log.error("Failed to start server:");
|
||||
RED.log.error(log._("failed-to-start-server"));
|
||||
if (err.stack) {
|
||||
RED.log.error(err.stack);
|
||||
} else {
|
||||
|
@ -36,7 +36,7 @@ function createLibrary(type) {
|
||||
}).otherwise(function(err) {
|
||||
if (err) {
|
||||
log.warn(log._("api.library.error-load-entry",{path:path,message:err}));
|
||||
if (err.message.indexOf('forbidden') === 0) {
|
||||
if (err.code === 'forbidden') {
|
||||
log.audit({event: "library.get",type:type,error:"forbidden"},req);
|
||||
res.send(403);
|
||||
return;
|
||||
@ -58,7 +58,7 @@ function createLibrary(type) {
|
||||
res.send(204);
|
||||
}).otherwise(function(err) {
|
||||
log.warn(log._("api.library.error-save-entry",{path:path,message:err}));
|
||||
if (err.message.indexOf('forbidden') === 0) {
|
||||
if (err.code === 'forbidden') {
|
||||
log.audit({event: "library.set",type:type,error:"forbidden"},req);
|
||||
res.send(403);
|
||||
return;
|
||||
@ -90,7 +90,7 @@ module.exports = {
|
||||
}).otherwise(function(err) {
|
||||
if (err) {
|
||||
log.warn(log._("api.library.error-load-flow",{path:req.params[0],message:err}));
|
||||
if (err.message.indexOf('forbidden') === 0) {
|
||||
if (err.code === 'forbidden') {
|
||||
log.audit({event: "library.get",type:"flow",path:req.params[0],error:"forbidden"},req);
|
||||
res.send(403);
|
||||
return;
|
||||
@ -107,7 +107,7 @@ module.exports = {
|
||||
res.send(204);
|
||||
}).otherwise(function(err) {
|
||||
log.warn(log._("api.library.error-save-flow",{path:req.params[0],message:err}));
|
||||
if (err.message.indexOf('forbidden') === 0) {
|
||||
if (err.code === 'forbidden') {
|
||||
log.audit({event: "library.set",type:"flow",path:req.params[0],error:"forbidden"},req);
|
||||
res.send(403);
|
||||
return;
|
||||
|
@ -43,7 +43,7 @@ function createNode(type,config) {
|
||||
});
|
||||
}
|
||||
} else {
|
||||
Log.error("Unknown type: "+type);
|
||||
Log.error(Log._("nodes.flow.unknown-type", {type:type}));
|
||||
}
|
||||
return nn;
|
||||
}
|
||||
@ -368,7 +368,7 @@ Flow.prototype.start = function(configDiff) {
|
||||
|
||||
this.started = true;
|
||||
if (this.missingTypes.length > 0) {
|
||||
throw new Error("missing types");
|
||||
throw new Error(Log._("nodes.flow.missing-types"));
|
||||
}
|
||||
events.emit("nodes-starting");
|
||||
|
||||
|
@ -17,6 +17,7 @@ var registry = require("./registry");
|
||||
var credentials = require("./credentials");
|
||||
var flows = require("./flows");
|
||||
var Node = require("./Node");
|
||||
var log = require("../log");
|
||||
|
||||
/**
|
||||
* Registers a node constructor
|
||||
@ -61,7 +62,7 @@ function init(_settings,storage,app) {
|
||||
function checkTypeInUse(id) {
|
||||
var nodeInfo = registry.getNodeInfo(id);
|
||||
if (!nodeInfo) {
|
||||
throw new Error("Unrecognised id: "+id);
|
||||
throw new Error(log._("nodes.index.unrecognised-id", {id:id}));
|
||||
} else {
|
||||
var inUse = {};
|
||||
var config = flows.getFlows();
|
||||
@ -76,7 +77,7 @@ function checkTypeInUse(id) {
|
||||
});
|
||||
if (nodesInUse.length > 0) {
|
||||
var msg = nodesInUse.join(", ");
|
||||
var err = new Error("Type in use: "+msg);
|
||||
var err = new Error(log._("nodes.index.type-in-use", {msg:msg}));
|
||||
err.code = "type_in_use";
|
||||
throw err;
|
||||
}
|
||||
@ -91,7 +92,7 @@ function removeNode(id) {
|
||||
function removeModule(module) {
|
||||
var info = registry.getModuleInfo(module);
|
||||
if (!info) {
|
||||
throw new Error("Unrecognised module: "+module);
|
||||
throw new Error(log._("nodes.index.unrecognised-module", {module:module}));
|
||||
} else {
|
||||
for (var i=0;i<info.nodes.length;i++) {
|
||||
checkTypeInUse(module+"/"+info.nodes[i].name);
|
||||
|
@ -302,7 +302,8 @@ function addModule(module) {
|
||||
}
|
||||
var nodes = [];
|
||||
if (registry.getModuleInfo(module)) {
|
||||
var e = new Error("Module already loaded");
|
||||
// TODO: nls
|
||||
var e = new Error("module_already_loaded");
|
||||
e.code = "module_already_loaded";
|
||||
return when.reject(e);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ var fs = require("fs");
|
||||
var path = require("path");
|
||||
|
||||
var events = require("../../events");
|
||||
var log = require("../../log");
|
||||
|
||||
var settings;
|
||||
var defaultNodesDir = path.resolve(path.join(__dirname,"..","..","..","nodes"));
|
||||
@ -251,7 +252,7 @@ function getModuleFiles(module) {
|
||||
|
||||
var moduleFiles = scanTreeForNodesModules(module);
|
||||
if (moduleFiles.length === 0) {
|
||||
var err = new Error("Cannot find module '" + module + "'");
|
||||
var err = new Error(log._("nodes.registry.localfilesystem.module-not-found", {module:module}));
|
||||
err.code = 'MODULE_NOT_FOUND';
|
||||
throw err;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
var when = require("when");
|
||||
var clone = require("clone");
|
||||
var assert = require("assert");
|
||||
var log = require("./log");
|
||||
|
||||
var userSettings = null;
|
||||
var globalSettings = null;
|
||||
@ -48,17 +49,17 @@ var persistentSettings = {
|
||||
return clone(userSettings[prop]);
|
||||
}
|
||||
if (globalSettings === null) {
|
||||
throw new Error("Settings not available");
|
||||
throw new Error(log._("settings.not-available"));
|
||||
}
|
||||
return clone(globalSettings[prop]);
|
||||
},
|
||||
|
||||
set: function(prop,value) {
|
||||
if (userSettings.hasOwnProperty(prop)) {
|
||||
throw new Error("Property '"+prop+"' is read-only");
|
||||
throw new Error(log._("settings.property-read-only", {prop:prop}));
|
||||
}
|
||||
if (globalSettings === null) {
|
||||
throw new Error("Settings not available");
|
||||
throw new Error(log._("settings.not-available"));
|
||||
}
|
||||
var current = globalSettings[prop];
|
||||
globalSettings[prop] = value;
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
var when = require('when');
|
||||
var Path = require('path');
|
||||
var log = require("../log");
|
||||
|
||||
var storageModule;
|
||||
var settingsAvailable;
|
||||
@ -96,13 +97,17 @@ var storageModuleInterface = {
|
||||
|
||||
getLibraryEntry: function(type, path) {
|
||||
if (is_malicious(path)) {
|
||||
return when.reject(new Error('forbidden flow name'));
|
||||
var err = new Error();
|
||||
err.code = "forbidden";
|
||||
return when.reject(err);
|
||||
}
|
||||
return storageModule.getLibraryEntry(type, path);
|
||||
},
|
||||
saveLibraryEntry: function(type, path, meta, body) {
|
||||
if (is_malicious(path)) {
|
||||
return when.reject(new Error('forbidden flow name'));
|
||||
var err = new Error();
|
||||
err.code = "forbidden";
|
||||
return when.reject(err);
|
||||
}
|
||||
return storageModule.saveLibraryEntry(type, path, meta, body);
|
||||
},
|
||||
@ -117,7 +122,9 @@ var storageModuleInterface = {
|
||||
},
|
||||
getFlow: function(fn) {
|
||||
if (is_malicious(fn)) {
|
||||
return when.reject(new Error('forbidden flow name'));
|
||||
var err = new Error();
|
||||
err.code = "forbidden";
|
||||
return when.reject(err);
|
||||
}
|
||||
if (storageModule.hasOwnProperty("getFlow")) {
|
||||
return storageModule.getFlow(fn);
|
||||
@ -128,7 +135,9 @@ var storageModuleInterface = {
|
||||
},
|
||||
saveFlow: function(fn, data) {
|
||||
if (is_malicious(fn)) {
|
||||
return when.reject(new Error('forbidden flow name'));
|
||||
var err = new Error();
|
||||
err.code = "forbidden";
|
||||
return when.reject(err);
|
||||
}
|
||||
if (storageModule.hasOwnProperty("saveFlow")) {
|
||||
return storageModule.saveFlow(fn, data);
|
||||
|
Loading…
Reference in New Issue
Block a user