How to use the node-red.httpNode 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
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 aspnet / Wave / app.js View on Github external
broker_username: config.broker.username,
        broker_password: config.broker.password,
        clientid: config.clientid,
        clientconfig: objUtil.extend(clientconfig, { "status": "online" }),
        clientconfig_offline: objUtil.extend(clientconfig, { "status": "offline" })
    }
};

// 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(8000);

// Start the runtime
RED.start();

console.log("=================================================");
console.log("Flows Dir      : " + path.resolve(settings.userDir));
console.log("Node-Red Url   : http://localhost:8000/red/");
console.log("=================================================");
github EdgeVerve / loopback-connector-nodes-for-Node-RED / node-red.js View on Github external
httpNodeRoot : '/redapi',
            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) {
github Streampunk / dynamorse-deprecated / server.js View on Github external
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') {
  RED.settings.functionGlobalContext.updated = false;
  // logger.removeAllListeners();
  nodeAPI.putResource(device).catch(RED.log.error);
github CommonGarden / Grow-IoT / imports / api / node-red / node-red.js View on Github external
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 samtecspg / conveyor / api / plugins / startup-install.plugin.js View on Github external
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);
        }, 1000 * 5);

    }).catch((err) => {
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 IBM-Blockchain / vehicle-manufacture / apps / manufacturer / server / src / server.ts View on Github external
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 bigclownlabs / bch-playground / src / background / NodeREDWorker.js View on Github external
console.log(source)
                                        console.log(target)
                                        copyFolderRecursiveSync(source, target);
                                    }
                                }
                            }
                        }
                    }
                }
            };

            let http_app = express();
            let server = http.createServer(http_app);
            RED.init(server, settings);
            http_app.use(settings.httpAdminRoot, RED.httpAdmin);
            http_app.use(settings.httpNodeRoot, RED.httpNode);

            RED.start().then(function () {
                server.listen(listenPort, "127.0.0.1", ()=>{
                    status = "online";

                    resolve();
                });
            });
        } else {
            status = "external";

            reject();
        }
    });
}
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);
  }