How to use the node-red.httpAdmin function in node-red

To help you get started, we’ve selected a few node-red examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TotallyInformation / node-red-template-embedded / server.js View on Github external
var certificate = fs.readFileSync("server.crt", "utf8");
  var credentials = {
    key: privateKey,
    cert: certificate
  };
}
var httpServer = use_https
  ? http.createServer(credentials, app)
  : http.createServer(app);

// Initialise the runtime with a server and settings
// @see http://nodered.org/docs/configuration.html
RED.init(httpServer, nrSettings);

// Serve the editor UI from /admin
app.use(nrSettings.httpAdminRoot, RED.httpAdmin);

// Serve the http nodes from /
app.use(nrSettings.httpNodeRoot, RED.httpNode);

httpServer.listen(http_port, listening_address, function() {
  console.info(
    "Express 4 https server listening on http%s://%s:%d%s, serving node-red",
    use_https ? "s" : "",
    httpServer.address().address.replace("0.0.0.0", "localhost"),
    httpServer.address().port,
    nrSettings.httpAdminRoot
  );
});

// Start the runtime
RED.start();
github EdgeVerve / loopback-connector-nodes-for-Node-RED / node-red.js View on Github external
userDir : 'nodered/',
            nodesDir : '../nodes',
            flowFile : 'node-red-flows.json',
            functionGlobalContext : {}
        // enables global context
        };
    }
    
    // Initialise the runtime with a server and settings
    RED.init(server, settings);
    // Serve the editor UI from /red
    app.use(settings.httpAdminRoot, RED.httpAdmin);
    
    // Serve the http nodes UI from /api
    app.use(settings.httpNodeRoot, RED.httpNode);
    var adminApp = RED.httpAdmin;
    var redNodes = RED.nodes;
    
    if (!options.settings.server) {
        
        var port = options ? options.port || 3001 : 3001;
        server.listen(port);
        RED.start().then(function () {
            return callback();
        });
    }
    else {
        // Start the runtime - removing earlier timeout implementation!!
        RED.start().then(function () {
            return callback();
        }).otherwise(function (err) {
            console.log('**ERROR : NODE RED WAS NOT STARTED ***' , err);
github ibm-watson-iot / iot-nodejs / samples / oldstuff / cognitive / app.js View on Github external
}

if (!couchService) {
    console.log("Failed to find Cloudant service");
    if (process.env.NODE_RED_STORAGE_NAME) {
        console.log(" - using NODE_RED_STORAGE_NAME environment variable: "+process.env.NODE_RED_STORAGE_NAME);
    }
    throw new Error("No cloudant service found");
}
settings.couchUrl = couchService.url;

// Initialise the runtime with a server and settings
RED.init( httpServer, settings );

// Serve the editor UI from /red
app.use( settings.httpAdminRoot, RED.httpAdmin );

// Serve the http nodes UI from /api
app.use( settings.httpNodeRoot, RED.httpNode );

httpServer.listen( port, function(){
    console.log('App listening on port: ', port);
});

// Start the runtime
RED.start();
github samtecspg / conveyor / api / plugins / startup-install.plugin.js View on Github external
logging: {
            // Console logging
            console: {
                level: 'error',
                metrics: false,
                audit: false
            }
        },
        functionGlobalContext: {}    // enables global context
    };

    // Initialise the runtime with a server and settings
    RED.init(server, settings);

    // Serve the editor UI from /red
    app.use(settings.httpAdminRoot, RED.httpAdmin);

    // Serve the http nodes UI from /api
    app.use(settings.httpNodeRoot, RED.httpNode);

    server.listen(1880);

    // Start the runtime
    RED.start().then(EmbeddedStart(RED)).then((result) => {

        // result is whatever RED.start() resolved to
        // RED.node.getFlows() etc are now ready to use

        //Still calls a little bit too fast so adding a delay.
        setTimeout(() => {

            callback(null);
github CommonGarden / Grow-IoT / app / imports / api / node-red / node-red.js View on Github external
httpRoot:"/red",
    httpNodeRoot: "/api",
    adminAuth: require("./user-authentication"),
    editorTheme: {
        projects: {
            enabled: true
        }
    },
    functionGlobalContext: { }    // enables global context
};

// Initialise the runtime with Meteor http server and settings
RED.init(WebApp.httpServer, settings);

// Serve the editor UI from /red
app.use(settings.httpRoot, RED.httpAdmin);

// Serve the http nodes UI from /api
app.use(settings.httpNodeRoot, RED.httpNode);

WebApp.connectHandlers.use('/', app);

RED.start();
github Streampunk / dynamorse-deprecated / server.js View on Github external
nodeAPI : nodeAPI,
      ledger : ledger,
      rtp_ext_id : extDefNodeID,
      pipelinesID : pipelines.id,
      genericID : device.id,
      updated : false
    },    // enables global context
    paletteCategories: ['subflows', 'funnel', 'valve', 'fitting', 'spout', 'testing', 'input', 'output', 'function', 'social', 'mobile', 'storage', 'analysis', 'advanced'],
    logging: { console : { level : "error", audit : false } }
};

// Initialise the runtime with a server and settings
RED.init(server,settings);

// Serve the editor UI from /red
app.use(settings.httpAdminRoot, RED.httpAdmin);

// Serve the http nodes UI from /api
app.use(settings.httpNodeRoot, RED.httpNode);

server.listen(+properties.redPort);

// Start the runtime - function can be used to do work after types are loaded
RED.start().then(function () {
  RED.log.info("STARTED!");
});

// Run flow configurations once flows are loaded
var EE = require('events').EventEmitter;
var logger = new EE();
RED.log.addHandler(logger);
logger.on('log', function (x) { if (x.msg === 'Starting flows') {
github IBM-Blockchain / vehicle-manufacture / apps / manufacturer / server / src / server.ts View on Github external
async function createServer() {
    const port = (await Config.readConfig()).manufacturer.port;

    const app = express();

    const server = http.createServer(app);

    const nodeRedSettings = {
        flowFile: path.join(__dirname, '../../config/node-red-flow.json'),
        httpAdminRoot: '/node-red',
        httpNodeRoot: '/node-red/api',
    };

    RED.init(server, nodeRedSettings);

    app.use(nodeRedSettings.httpAdminRoot, RED.httpAdmin);
    app.use(nodeRedSettings.httpNodeRoot, RED.httpNode);

    await setup(app, SERVER_CONFIG);

    server.listen(port, () => {
        console.log(`Server started on port ${port}`);
    });

    RED.start();
}
github jmservera / node-red-azure-webapp / server.js View on Github external
//jshint esversion:6
var express = require("express");
var RED=require('node-red');
var app= express();
 var http=require('http');

const PORT=process.env.PORT||8000;

var server=http.createServer(app);
var settings=require("./settings.js");

RED.init(server,settings);

app.use(settings.httpAdminRoot,RED.httpAdmin);
app.use(settings.httpNodeRoot,RED.httpNode);
 
 server.listen(settings.uiPort);
console.log(`listening port:${settings.uiPort}`);
RED.start();
github sakazuki / node-red-desktop / src / main / node-red.ts View on Github external
private setupRED() {
    log.debug(">>> settings", this.settings);
    RED.init(this.server, this.settings);
    this.setupDebugOut()
    this.app.use(this.settings.httpAdminRoot, RED.httpAdmin);
    if (this.settings.httpNodeAuth) {
      this.app.use(
        this.settings.httpNodeRoot,
        this.basicAuthMiddleware(
          this.settings.httpNodeAuth.user,
          this.settings.httpNodeAuth.pass
        )
      );
    }
    this.app.use(this.settings.httpNodeRoot, RED.httpNode);
  }