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

Add credential registration to RED.nodes.registerType

This commit is contained in:
Nick O'Leary 2014-07-18 14:20:49 +01:00
parent f80c41058c
commit a6a0352b70

View File

@ -18,6 +18,18 @@ var credentials = require("./credentials");
var flows = require("./flows"); var flows = require("./flows");
var Node = require("./Node"); var Node = require("./Node");
/**
* Registers a node constructor
* @param type - the string type name
* @param constructor - the constructor function for this node type
* @param opts - optional additional options for the node
*/
function registerType(type,constructor,opts) {
if (opts && opts.credentials) {
credentials.register(type,opts.credentials);
}
registry.registerType(type,constructor);
}
function createNode(node,def) { function createNode(node,def) {
Node.call(node,def); Node.call(node,def);
@ -33,11 +45,10 @@ function init(_settings,storage) {
module.exports = { module.exports = {
init: init, init: init,
load: registry.load, load: registry.load,
addCredentials: credentials.add,
getCredentials: credentials.get,
deleteCredentials: credentials.delete,
createNode: createNode, createNode: createNode,
registerType: registry.registerType, registerType: registerType,
getType: registry.get, getType: registry.get,
getNodeConfigs: registry.getNodeConfigs, getNodeConfigs: registry.getNodeConfigs,
getNode: flows.get, getNode: flows.get,
@ -45,6 +56,11 @@ module.exports = {
loadFlows: flows.load, loadFlows: flows.load,
stopFlows: flows.stopFlows, stopFlows: flows.stopFlows,
setFlows: flows.setFlows, setFlows: flows.setFlows,
getFlows: flows.getFlows getFlows: flows.getFlows,
// TODO: remove these from api - see #93
addCredentials: credentials.add,
getCredentials: credentials.get,
deleteCredentials: credentials.delete
} }