More api documentation updates

This commit is contained in:
Nick O'Leary
2019-01-28 14:40:24 +00:00
parent 2e063f91bc
commit e0bb03a53f
7 changed files with 109 additions and 4 deletions

View File

@@ -14,6 +14,11 @@
* limitations under the License.
**/
/**
* @mixin @node-red/editor-api_auth
*/
var passport = require("passport");
var oauth2orize = require("oauth2orize");
@@ -44,7 +49,14 @@ function init(_settings,storage) {
Tokens.init(mergedAdminAuth,storage);
}
}
/**
* Returns an Express middleware function that ensures the user making a request
* has the necessary permission.
*
* @param {String} permission - the permission required for the request, such as `flows.write`
* @return {Function} - an Express middleware
* @memberof @node-red/editor-api_auth
*/
function needsPermission(permission) {
return function(req,res,next) {
if (settings && settings.adminAuth) {

View File

@@ -14,6 +14,16 @@
* limitations under the License.
**/
/**
* This module provides an Express application to serve the Node-RED editor.
*
* It implements the Node-RED HTTP Admin API the Editor uses to interact
* with the Node-RED runtime.
*
* @namespace @node-red/editor-api
*/
var express = require("express");
var bodyParser = require("body-parser");
var util = require('util');
@@ -28,6 +38,15 @@ var adminApp;
var server;
var editor;
/**
* Initialise the module.
* @param {Object} settings The runtime settings
* @param {HTTPServer} server An instance of HTTP Server
* @param {Storage} storage An instance of Node-RED Storage
* @param {Runtime} runtimeAPI An instance of Node-RED Runtime
* @memberof @node-red/editor-api
*/
function init(settings,_server,storage,runtimeAPI) {
server = _server;
if (settings.httpAdminRoot !== false) {
@@ -80,6 +99,12 @@ function init(settings,_server,storage,runtimeAPI) {
adminApp = null;
}
}
/**
* Start the module.
* @return {Promise} resolves when the application is ready to handle requests
* @memberof @node-red/editor-api
*/
function start() {
if (editor) {
return editor.start();
@@ -87,6 +112,12 @@ function start() {
return when.resolve();
}
}
/**
* Stop the module.
* @return {Promise} resolves when the application is stopped
* @memberof @node-red/editor-api
*/
function stop() {
if (editor) {
editor.stop();
@@ -97,8 +128,18 @@ module.exports = {
init: init,
start: start,
stop: stop,
/**
* @memberof @node-red/editor-api
* @mixes @node-red/editor-api_auth
*/
auth: {
needsPermission: auth.needsPermission
},
/**
* The Express app used to serve the Node-RED Editor
* @type ExpressApplication
* @memberof @node-red/editor-api
*/
get httpAdmin() { return adminApp; }
};

View File

@@ -14,6 +14,16 @@
* limitations under the License.
**/
/**
* This module provides the node registry for the Node-RED runtime.
*
* It is responsible for loading node modules and making them available
* to the runtime.
*
* @namespace @node-red/registry
*/
var registry = require("./registry");
var loader = require("./loader");
var installer = require("./installer");

View File

@@ -122,6 +122,13 @@ module.exports = {
*/
util: redUtil.util,
/**
* This provides access to the internal nodes module of the
* runtime.
*
* @memberof node-red
*/
get nodes() { return runtime._.nodes },
/**
@@ -131,6 +138,12 @@ module.exports = {
*/
events: runtime.events,
/**
* This provides access to the internal settings module of the
* runtime.
*
* @memberof node-red
*/
get settings() { return runtime._.settings },
@@ -145,18 +158,21 @@ module.exports = {
/**
* The express application for the Editor Admin API
* @type ExpressApplication
* @memberof node-red
*/
get httpAdmin() { return api.httpAdmin },
/**
* The express application for HTTP Nodes
* @type ExpressApplication
* @memberof node-red
*/
get httpNode() { return runtime.httpNode },
/**
* The HTTP Server used by the runtime
* @type HTTPServer
* @memberof node-red
*/
get server() { return server },
@@ -170,6 +186,7 @@ module.exports = {
/**
* The editor authentication api.
* @see @node-red/editor-api_auth
* @memberof node-red
*/
auth: api.auth