Skip to content

Instantly share code, notes, and snippets.

@beevelop
Created March 9, 2020 19:04
Show Gist options
  • Save beevelop/fddca683c4081eef295b680bcebf18c9 to your computer and use it in GitHub Desktop.
Save beevelop/fddca683c4081eef295b680bcebf18c9 to your computer and use it in GitHub Desktop.
Node-RED embedded (standalone)
var RED = require("node-red");
var importedFlows = require('./flows.json')
const path = require('path');
// Create the settings object - see default settings.js file for other options
var settings = {
httpNodeRoot: false,
httpAdminRoot: false,
userDir: path.join(__dirname, ".nodered"),
functionGlobalContext: {}
};
const init = async () => {
// Initialise the runtime with a server and settings
RED.init(null, settings);
await RED.start();
let foo = await RED.runtime.flows.setFlows(
{
flows: { flows: importedFlows },
deploymentType: 'flows'
}
)
console.log(await RED.runtime.flows.getFlows())
}
init()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment