### Admin Authentication Example Source: https://github.com/gladysassistant/gladys/blob/master/server/services/node-red/docker/settings.txt Example configuration for setting up admin authentication with username and password hash. ```javascript adminAuth: { type: 'credentials', users: [{ username: 'admin', password: '$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN.', permissions: '*' }] } ``` -------------------------------- ### Example Service Folder Structure Source: https://github.com/gladysassistant/gladys/blob/master/server/services/example/README.md The typical folder structure for an example service, including lib, index.js, package-lock.json, package.json, and README. ```text -- lib ---- light ------ light.turnOn.js ------ light.turnOff.js ------ light.getState.js ------ index.js -- index.js -- package-lock.json -- package.json -- README ``` -------------------------------- ### Mocking Dependencies with Proxyquire Source: https://github.com/gladysassistant/gladys/blob/master/server/services/example/README.md An example of how to use proxyquire to mock third-party libraries like axios during testing. ```javascript const proxyquire = require('proxyquire').noCallThru(); const MockedClient = { create: function create() { return { post: (url) => Promise.resolve(logger.info(`Turning On Light, calling ${url}`)), get: (url) => Promise.resolve(5), }; }, }; const ExampleService = proxyquire('../../../services/example/index', { axios: MockedClient, }); ``` -------------------------------- ### HTTP Static Authentication Example Source: https://github.com/gladysassistant/gladys/blob/master/server/services/node-red/docker/settings.txt Example configuration for password protecting static content. ```javascript httpStaticAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."} ``` -------------------------------- ### FreeBSD GNU Make Installation Source: https://github.com/gladysassistant/gladys/blob/master/server/services/bluetooth/README.md Command to install GNU Make on FreeBSD. ```bash sudo pkg install gmake ``` -------------------------------- ### Example Service API Exposure Source: https://github.com/gladysassistant/gladys/blob/master/server/services/example/README.md The functions exposed by the example service, including start, stop, and light control functions (turnOn, turnOff, getState). ```text { start: [Function], // function to start the service stop: [Function], // function to stop the service light: { turnOn: [Function], // function to turnOn the light turnOff: [Function], // function to turnOff the light getState: [Function], // function to get the state of the light (on/off) } } ``` -------------------------------- ### Context Storage Configuration Example Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedOtherNodeRedContent.txt An example of how to configure file-based context storage that flushes to disk every 30 seconds. ```javascript // contextStorage: { // default: { // module:"localfilesystem" // }, // }, ``` -------------------------------- ### HTTP Node Authentication Example Source: https://github.com/gladysassistant/gladys/blob/master/server/services/node-red/docker/settings.txt Example configuration for password protecting node-defined HTTP endpoints. ```javascript httpNodeAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."} ``` -------------------------------- ### Docker Installation Source: https://github.com/gladysassistant/gladys/blob/master/README.md Spin up a local Gladys Assistant instance in seconds using Docker. ```bash sudo docker run -d \ --log-driver json-file \ --log-opt max-size=10m \ --cgroupns=host \ --restart=always \ --privileged \ --network=host \ --name gladys \ -e NODE_ENV=production \ -e SERVER_PORT=80 \ -e TZ=Europe/Paris \ -e SQLITE_FILE_PATH=/var/lib/gladysassistant/gladys-production.db \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /var/lib/gladysassistant:/var/lib/gladysassistant \ -v /dev:/dev \ -v /run/udev:/run/udev:ro \ gladysassistant/gladys:v4 ``` -------------------------------- ### HTTP Static Configuration Example (Multiple Sources) Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedOtherNodeRedContent.txt Example of configuring multiple directories with specific root paths for static content served by Node-RED. ```javascript httpStatic: [ {path: '/home/nol/pics/', root: "/img/"}, {path: '/home/nol/reports/', root: "/doc/"}, ] ``` -------------------------------- ### HTTP Static Configuration Example (Single Source) Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedOtherNodeRedContent.txt Example of configuring a single directory for static content served by Node-RED. ```javascript httpStatic: '/home/nol/node-red-static/' ``` -------------------------------- ### Ubuntu/Debian/Raspbian Installation Source: https://github.com/gladysassistant/gladys/blob/master/server/services/bluetooth/README.md Command to install necessary Bluetooth packages on Ubuntu, Debian, and Raspbian. ```bash sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev ``` -------------------------------- ### Modules Configuration Example Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedDefaultContent.txt Configuration for node-specified modules. ```javascript // modules: { /** Configuration for node-specified modules */ // allowInstall: true, // allowList: [], // denyList: [] // } ``` -------------------------------- ### Package.json structure for a service Source: https://github.com/gladysassistant/gladys/blob/master/server/services/example/README.md The package.json file defines the service's name, main entry point, compatible operating systems and CPUs, and dependencies. ```json { "name": "gladys-example", "main": "index.js", "os": ["darwin", "linux", "win32"], "cpu": ["x64", "arm", "arm64"], "scripts": {}, "dependencies": { "axios": "^^0.21.1" } } ``` -------------------------------- ### Windows Build Tools Installation Source: https://github.com/gladysassistant/gladys/blob/master/server/services/bluetooth/README.md Command to install required build tools on Windows using npm. ```cmd npm install --global --production windows-build-tools ``` -------------------------------- ### HTTPS Configuration - Static Object Source: https://github.com/gladysassistant/gladys/blob/master/server/services/node-red/docker/settings.txt Example of configuring HTTPS using a static object with key and certificate paths. ```javascript https: { key: require("fs").readFileSync('privkey.pem'), cert: require("fs").readFileSync('cert.pem') } ``` -------------------------------- ### HTTP Node Middleware Example Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedOtherNodeRedContent.txt Example of adding custom middleware to Node-RED HTTP in nodes for request processing. ```javascript httpNodeMiddleware: function(req,res,next) { // Handle/reject the request, or pass it on to the http in node by calling next(); // Optionally skip our rawBodyParser by setting this to true; //req.skipRawBodyParser = true; next(); } ``` -------------------------------- ### HTTP Admin Middleware Example Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedOtherNodeRedContent.txt Example of adding custom middleware to Node-RED admin HTTP routes to set headers. ```javascript httpAdminMiddleware: function(req,res,next) { // Set the X-Frame-Options header to limit where the editor // can be embedded //res.set('X-Frame-Options', 'sameorigin'); next(); } ``` -------------------------------- ### Editor Theme Configuration Example Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedDefaultContent.txt Configuration for custom editor themes. ```javascript editorTheme: { /** * The following property can be used to set a custom theme for the editor. * See https://github.com/node-red-contrib-themes/theme-collection for * a collection of themes to chose from. */ // theme: "", /** * To disable the 'Welcome to Node-RED' tour that is displayed the first * time you access the editor for each release of Node-RED, set this to false. */ // tours: false, palette: { /** * The following property can be used to order the categories in the editor * palette. If a node's category is not in the list, the category will get * added to the end of the palette. * If not set, the following default order is used: */ // categories: ['subflows', 'common', 'function', 'network', 'sequence', 'parser', 'storage'], }, projects: { /** To enable the Projects feature, set this value to true */ enabled: false, workflow: { /** * Set the default projects workflow mode. * - manual - you must manually commit changes * - auto - changes are automatically committed * This can be overridden per-user from the 'Git config' * section of 'User Settings' within the editor. */ mode: 'manual' } }, codeEditor: { /** * Select the text editor component used by the editor. * As of Node-RED V3, this defaults to "monaco", but can be set to "ace" if desired. */ lib: 'monaco', options: { /** * The follow options only apply if the editor is set to "monaco". * * Theme - must match the file name of a theme in * packages/node_modules/@node-red/editor-client/src/vendor/monaco/dist/theme * e.g. "tomorrow-night", "upstream-sunburst", "github", "my-theme". */ // theme: "vs", /** * Other overrides can be set e.g. FontSize, fontFamily, fontLigatures etc. * For the full list, see https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.IStandaloneEditorConstructionOptions.html. */ // fontSize: 14, // fontFamily: "Cascadia Code, Fira Code, Consolas, 'Courier New', monospace", // fontLigatures: true, } } } ``` -------------------------------- ### HTTPS Configuration - Function Source: https://github.com/gladysassistant/gladys/blob/master/server/services/node-red/docker/settings.txt Example of configuring HTTPS using a function that returns the HTTP configuration object. ```javascript https: function() { // This function should return the options object, or a Promise // that resolves to the options object return { key: require("fs").readFileSync('privkey.pem'), cert: require("fs").readFileSync('cert.pem') } } ``` -------------------------------- ### CLI Commands Source: https://github.com/gladysassistant/gladys/blob/master/front/README.md Commands for installing dependencies, serving with hot reload, and building for production. ```bash # install dependencies npm install # serve with hot reload at localhost:1444 npm start # build for production with minification npm run build ``` -------------------------------- ### Fedora / Other-RPM based Installation Source: https://github.com/gladysassistant/gladys/blob/master/server/services/bluetooth/README.md Command to install necessary Bluetooth packages on Fedora and other RPM-based systems. ```bash sudo yum install bluez bluez-libs bluez-libs-devel ``` -------------------------------- ### Language Configuration Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedOtherNodeRedContent.txt Example of how to uncomment and set the preferred language for Node-RED. ```javascript // lang: "de", ``` -------------------------------- ### External Modules Configuration Example Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedOtherNodeRedContent.txt Configuration options for managing external npm modules, including auto-installation and palette manager settings. ```javascript externalModules: { // autoInstall: false, /** Whether the runtime will attempt to automatically install missing modules */ // autoInstallRetry: 30, /** Interval, in seconds, between reinstall attempts */ // palette: { /** Configuration for the Palette Manager */ // allowInstall: true, /** Enable the Palette Manager in the editor */ // allowUpdate: true, /** Allow modules to be updated in the Palette Manager */ // allowUpload: true, /** Allow module tgz files to be uploaded and installed */ // allowList: ['*'], // denyList: [], // allowUpdateList: ['*'], // denyUpdateList: [] // }, // modules: { /** Configuration for node-specified modules */ ``` -------------------------------- ### Function Global Context Example Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedDefaultContent.txt Setting predefined values in Global Context for Function nodes. ```javascript functionGlobalContext: { // os:require('os'), } ``` -------------------------------- ### HTTP Node CORS Configuration Example Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedOtherNodeRedContent.txt Basic permissive CORS configuration for Node-RED HTTP nodes. ```javascript httpNodeCors: { origin: "*", methods: "GET,PUT,POST,DELETE" } ``` -------------------------------- ### HTTP Static Configuration (Single Source) Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedDefaultContent.txt Specifies a directory to serve static content from when the UI is at a different root path. This example shows a single directory. ```javascript // httpStatic: '/home/nol/node-red-static/', //single static source ``` -------------------------------- ### Default Node-RED Settings Structure Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedDefaultContent.txt This is the default settings file structure for Node-RED, which can contain valid JavaScript code to be run on startup. Lines starting with // are comments, and entries are separated by commas. It covers various configuration sections like Flow File, Security, Server, Runtime, Editor, and Node settings. ```javascript /** * This is the default settings file provided by Node-RED. * * It can contain any valid JavaScript code that will get run when Node-RED * is started. * * Lines that start with // are commented out. * Each entry should be separated from the entries above and below by a comma ",". * * For more information about individual settings, refer to the documentation: * https://nodered.org/docs/user-guide/runtime/configuration. * * The settings are split into the following sections: * - Flow File and User Directory Settings * - Security * - Server Settings * - Runtime Settings * - Editor Settings * - Node Settings. * */ module.exports = { /** * *****************************************************************************. * Flow File and User Directory Settings * - flowFile * - credentialSecret * - flowFilePretty * - userDir * - nodesDir *****************************************************************************. */ /** The file containing the flows. If not set, defaults to flows_.json */ flowFile: 'flows.json', /** * By default, credentials are encrypted in storage using a generated key. To * specify your own secret, set the following property. * If you want to disable encryption of credentials, set this property to false. * Note: once you set this property, do not change it - doing so will prevent * node-red from being able to decrypt your existing credentials and they will be * lost. */ // credentialSecret: "a-secret-key", /** * By default, the flow JSON will be formatted over multiple lines making * it easier to compare changes when using version control. * To disable pretty-printing of the JSON set the following property to false. */ flowFilePretty: true, /** * By default, all user data is stored in a directory called `.node-red` under * the user's home directory. To use a different location, the following * property can be used. */ // userDir: '/home/nol/.node-red/', /** * Node-RED scans the `nodes` directory in the userDir to find local node files. * The following property can be used to specify an additional directory to scan. */ // nodesDir: '/home/nol/.node-red/nodes', /** * *****************************************************************************. * Security * - adminAuth * - https * - httpsRefreshInterval * - requireHttps * - httpNodeAuth * - httpStaticAuth *****************************************************************************. */ /** * To password protect the Node-RED editor and admin API, the following * property can be used. See http://nodered.org/docs/security.html for details. */ adminAuth: { type: 'credentials', users: [{ username: 'admin', password: '$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN.', permissions: '*' }] }, /** * The following property can be used to enable HTTPS * This property can be either an object, containing both a (private) key * and a (public) certificate, or a function that returns such an object. * See http://nodejs.org/api/https.html#https_https_createserver_options_requestlistener * for details of its contents. */ /** Option 1: static object */ // https: { // key: require("fs").readFileSync('privkey.pem'), // cert: require("fs").readFileSync('cert.pem') // }, /** Option 2: function that returns the HTTP configuration object */ // https: function() { // // This function should return the options object, or a Promise // // that resolves to the options object // return { // key: require("fs").readFileSync('privkey.pem'), // cert: require("fs").readFileSync('cert.pem') // } // }, /** * If the `https` setting is a function, the following setting can be used * to set how often, in hours, the function will be called. That can be used * to refresh any certificates. */ // httpsRefreshInterval : 12, /** * The following property can be used to cause insecure HTTP connections to * be redirected to HTTPS. */ // requireHttps: true, /** * To password protect the node-defined HTTP endpoints (httpNodeRoot), * including node-red-dashboard, or the static content (httpStatic), the * following properties can be used. * The `pass` field is a bcrypt hash of the password. * See http://nodered.org/docs/security.html#generating-the-password-hash. */ // httpNodeAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."}, // httpStaticAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."}, /** * *****************************************************************************. * Server Settings ``` -------------------------------- ### External Modules Configuration Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedNodeRedContent.txt Configure how the runtime will handle external npm modules. This covers: whether the editor will allow new node modules to be installed, and whether nodes, such as the Function node are allowed to have their own dynamically configured dependencies. The allow/denyList options can be used to limit what modules the runtime will install/load. It can use '*' as a wildcard that matches anything. ```javascript externalModules: { // autoInstall: false, /** Whether the runtime will attempt to automatically install missing modules */ // autoInstallRetry: 30, /** Interval, in seconds, between reinstall attempts */ // palette: { /** Configuration for the Palette Manager */ // allowInstall: true, /** Enable the Palette Manager in the editor */ // allowUpdate: true, /** Allow modules to be updated in the Palette Manager */ // allowUpload: true, /** Allow module tgz files to be uploaded and installed */ // allowList: ['*'], // denyList: [], // allowUpdateList: ['*'], // denyUpdateList: [] // }, // modules: { /** Configuration for node-specified modules */ ``` -------------------------------- ### Static Content Serving Source: https://github.com/gladysassistant/gladys/blob/master/server/services/node-red/docker/settings.txt Configuration for serving static content from specified directories, with options for single or multiple sources. ```javascript /** * When httpAdminRoot is used to move the UI to a different root path, the * following property can be used to identify a directory of static content * that should be served at http://localhost:1880/. * When httpStaticRoot is set differently to httpAdminRoot, there is no need * to move httpAdminRoot. */ // httpStatic: '/home/nol/node-red-static/', //single static source /* OR multiple static sources can be created using an array of objects... */ // httpStatic: [ // {path: '/home/nol/pics/', root: "/img/"}, // {path: '/home/nol/reports/', root: "/doc/"}, // ], /** * All static routes will be appended to httpStaticRoot * e.g. If httpStatic = "/home/nol/docs" and httpStaticRoot = "/static/" * then "/home/nol/docs" will be served at "/static/" * e.g. if httpStatic = [{path: '/home/nol/pics/', root: "/img/"}] * and httpStaticRoot = "/static/" * then "/home/nol/pics/" will be served at "/static/img/". */ // httpStaticRoot: '/static/', ``` -------------------------------- ### HTTP Static Configuration (Multiple Sources) Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedDefaultContent.txt Allows serving static content from multiple directories by providing an array of objects, each with a path and a root for serving. ```javascript // httpStatic: [ // {path: '/home/nol/pics/', root: "/img/"}, // {path: '/home/nol/reports/', root: "/doc/"}, // ], ``` -------------------------------- ### Nuki MQTT Handler Initialization Source: https://github.com/gladysassistant/gladys/blob/master/server/services/nuki/README.md Initialization of the NukiMqttHandler, which depends on the NukiHandler. ```javascript const nukiMQTTHandler = new NukiMqttHandler(nukiHandler); ``` -------------------------------- ### Nuki Controller Initialization Source: https://github.com/gladysassistant/gladys/blob/master/server/services/nuki/README.md Initialization of the NukiController with the NukiHandler. ```javascript const NukiController = require('./api/nuki.controller'); controllers: NukiController(nukiHandler); ``` -------------------------------- ### HTTP Static Root Configuration Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedDefaultContent.txt Defines the root path under which static content specified in `httpStatic` will be served. ```javascript // httpStaticRoot: '/static/', ``` -------------------------------- ### Nuki Handler Initialization Source: https://github.com/gladysassistant/gladys/blob/master/server/services/nuki/README.md Initialization of the NukiHandler with Gladys instance and service ID. ```javascript const nukiHandler = new NukiHandler(gladys, serviceId); ``` -------------------------------- ### Context Storage Configuration Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedNodeRedContent.txt The following property can be used to enable context storage. The configuration provided here will enable file-based context that flushes to disk every 30 seconds. Refer to the documentation for further options: https://nodered.org/docs/api/context/. ```javascript // contextStorage: { // default: { // module:"localfilesystem" // }, // }, ``` -------------------------------- ### HTTP Admin Root and Middleware Source: https://github.com/gladysassistant/gladys/blob/master/server/services/node-red/docker/settings.txt Settings for customizing the root path of the Node-RED UI and adding custom middleware for admin routes. ```javascript /** * By default, the Node-RED UI is available at http://localhost:1880/ * The following property can be used to specify a different root path. * If set to false, this is disabled. */ // httpAdminRoot: '/admin', /** * The following property can be used to add a custom middleware function * in front of all admin http routes. For example, to set custom http * headers. It can be a single function or an array of middleware functions. */ // httpAdminMiddleware: function(req,res,next) { // // Set the X-Frame-Options header to limit where the editor // // can be embedded // //res.set('X-Frame-Options', 'sameorigin'); // next(); // }, ``` -------------------------------- ### Node-RED Configuration Options Source: https://github.com/gladysassistant/gladys/blob/master/server/services/node-red/docker/settings.txt Configuration options for Node-RED, including message buffering, dashboard path, debug settings, and connection timeouts. ```javascript { /** * The maximum number of messages nodes will buffer internally as part of their * operation. This applies across a range of nodes that operate on message sequences. * Defaults to no limit. A value of 0 also means no limit is applied. */ // nodeMessageBufferMaxLength: 0, /** * If you installed the optional node-red-dashboard you can set it's path * relative to httpNodeRoot * Other optional properties include * readOnly:{boolean}, * middleware:{function or array}, (req,res,next) - http middleware * ioMiddleware:{function or array}, (socket,next) - socket.io middleware. */ // ui: { path: "ui" }, /** Colourise the console output of the debug node */ // debugUseColors: true, /** The maximum length, in characters, of any message sent to the debug sidebar tab */ debugMaxLength: 1000, /** Maximum buffer size for the exec node. Defaults to 10Mb */ // execMaxBufferSize: 10000000, /** Timeout in milliseconds for HTTP request connections. Defaults to 120s */ // httpRequestTimeout: 120000, /** Retry time in milliseconds for MQTT connections */ mqttReconnectTime: 15000, /** Retry time in milliseconds for Serial port connections */ serialReconnectTime: 15000, /** Retry time in milliseconds for TCP socket connections */ // socketReconnectTime: 10000, /** Timeout in milliseconds for TCP server socket connections. Defaults to no timeout */ // socketTimeout: 120000, /** * Maximum number of messages to wait in queue while attempting to connect to TCP socket * defaults to 1000. */ // tcpMsgQueueSize: 2000, /** * Timeout in milliseconds for inbound WebSocket connections that do not * match any configured node. Defaults to 5000. */ // inboundWebSocketTimeout: 5000, /** * To disable the option for using local files for storing keys and * certificates in the TLS configuration node, set this to true. */ // tlsConfigDisableLocalFiles: true, /** * The following property can be used to verify websocket connection attempts. * This allows, for example, the HTTP request headers to be checked to ensure * they include valid authentication information. */ // webSocketNodeVerifyClient: function(info) { // /** 'info' has three properties: // * - origin : the value in the Origin header // * - req : the HTTP request // * - secure : true if req.connection.authorized or req.connection.encrypted is set // * // * The function should return true if the connection should be accepted, false otherwise. // * // * Alternatively, if this function is defined to accept a second argument, callback, // * it can be used to verify the client asynchronously. // * The callback takes three arguments: // * - result : boolean, whether to accept the connection or not // * - code : if result is false, the HTTP error status to return // * - reason: if result is false, the HTTP reason string to return // */ // }, } ``` -------------------------------- ### Default Node-RED Settings Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedNodeRedContent.txt This is the default settings file provided by Node-RED, which can contain any valid JavaScript code. ```javascript /** * This is the default settings file provided by Node-RED. * * It can contain any valid JavaScript code that will get run when Node-RED * is started. * * Lines that start with // are commented out. * Each entry should be separated from the entries above and below by a comma ",". * * For more information about individual settings, refer to the documentation: * https://nodered.org/docs/user-guide/runtime/configuration. * * The settings are split into the following sections: * - Flow File and User Directory Settings * - Security * - Server Settings * - Runtime Settings * - Editor Settings * - Node Settings. * */ module.exports = { /** * *****************************************************************************. * Flow File and User Directory Settings * - flowFile * - credentialSecret * - flowFilePretty * - userDir * - nodesDir *****************************************************************************. */ /** The file containing the flows. If not set, defaults to flows_.json */ flowFile: 'flows.json', /** * By default, credentials are encrypted in storage using a generated key. To * specify your own secret, set the following property. * If you want to disable encryption of credentials, set this property to false. * Note: once you set this property, do not change it - doing so will prevent * node-red from being able to decrypt your existing credentials and they will be * lost. */ // credentialSecret: "a-secret-key", /** * By default, the flow JSON will be formatted over multiple lines making * it easier to compare changes when using version control. * To disable pretty-printing of the JSON set the following property to false. */ flowFilePretty: true, /** * By default, all user data is stored in a directory called `.node-red` under * the user's home directory. To use a different location, the following * property can be used. */ // userDir: '/home/nol/.node-red/', /** * Node-RED scans the `nodes` directory in the userDir to find local node files. * The following property can be used to specify an additional directory to scan. */ // nodesDir: '/home/nol/.node-red/nodes', /** * *****************************************************************************. * Security * - adminAuth * - https * - httpsRefreshInterval * - requireHttps * - httpNodeAuth * - httpStaticAuth *****************************************************************************. */ /** * To password protect the Node-RED editor and admin API, the following * property can be used. See http://nodered.org/docs/security.html for details. */ adminAuth: { type: 'credentials', users: [{ username: 'username', password: 'password', permissions: '*' }] }, /** * The following property can be used to enable HTTPS * This property can be either an object, containing both a (private) key * and a (public) certificate, or a function that returns such an object. * See http://nodejs.org/api/https.html#https_https_createserver_options_requestlistener * for details of its contents. */ /** Option 1: static object */ // https: { // key: require("fs").readFileSync('privkey.pem'), // cert: require("fs").readFileSync('cert.pem') // }, /** Option 2: function that returns the HTTP configuration object */ // https: function() { // // This function should return the options object, or a Promise // // that resolves to the options object // return { // key: require("fs").readFileSync('privkey.pem'), // cert: require("fs").readFileSync('cert.pem') // } // }, /** * If the `https` setting is a function, the following setting can be used * to set how often, in hours, the function will be called. That can be used * to refresh any certificates. */ // httpsRefreshInterval : 12, /** * The following property can be used to cause insecure HTTP connections to * be redirected to HTTPS. */ // requireHttps: true, /** * To password protect the node-defined HTTP endpoints (httpNodeRoot), * including node-red-dashboard, or the static content (httpStatic), the * following properties can be used. * The `pass` field is a bcrypt hash of the password. * See http://nodered.org/docs/security.html#generating-the-password-hash. */ // httpNodeAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."}, // httpStaticAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."}, /** * *****************************************************************************. * Server Settings * - uiPort * - uiHost * - apiMaxLength ``` -------------------------------- ### Logging Configuration Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedOtherNodeRedContent.txt Configuration for console logging, including setting the log level and options for including metrics and audit events. ```javascript logging: { /** Only console logging is currently supported */ console: { /** * Level of logging to be recorded. Options are: * fatal - only those errors which make the application unusable should be recorded * error - record errors which are deemed fatal for a particular request + fatal errors * warn - record problems which are non fatal + errors + fatal errors * info - record information about the general running of the application + warn + error + fatal errors * debug - record information which is more verbose than info + info + warn + error + fatal errors * trace - record very detailed logging + debug + info + warn + error + fatal errors * off - turn off all logging (doesn't affect metrics or audit). */ level: 'info', /** Whether or not to include metric events in the log output */ metrics: false, /** Whether or not to include audit events in the log output */ audit: false } } ``` -------------------------------- ### UI Host Configuration Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedDefaultContent.txt Configures the network interface the Node-RED UI listens on. '0.0.0.0' listens on all IPv4 interfaces. '::' listens on all IPv6 interfaces. ```javascript uiHost: "0.0.0.0", ``` -------------------------------- ### Network and API Settings Source: https://github.com/gladysassistant/gladys/blob/master/server/services/node-red/docker/settings.txt Configuration for the Node-RED web server port, host, and API request size. ```javascript /** The tcp port that the Node-RED web server is listening on */ uiPort: process.env.PORT || 1880, /** * By default, the Node-RED UI accepts connections on all IPv4 interfaces. * To listen on all IPv6 addresses, set uiHost to "::", * The following property can be used to listen on a specific interface. For * example, the following would only allow connections from the local machine. */ uiHost: "0.0.0.0", /** * The maximum size of HTTP request that will be accepted by the runtime api. * Default: 5mb. */ // apiMaxLength: '5mb', ``` -------------------------------- ### HTTP Server Options Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedNodeRedContent.txt Configuration options for the Node-RED HTTP server, including port, host, and root paths for the admin UI and nodes. ```javascript uiPort: process.env.PORT || 1880, uiHost: "0.0.0.0", // apiMaxLength: '5mb', // httpServerOptions: { }, // httpAdminRoot: '/admin', // httpAdminMiddleware: function(req,res,next) { // // Set the X-Frame-Options header to limit where the editor // // can be embedded // //res.set('X-Frame-Options', 'sameorigin'); // next(); // }, // httpNodeRoot: '/red-nodes', // httpNodeCors: { // origin: "*", // methods: "GET,PUT,POST,DELETE" // }, // httpNodeMiddleware: function(req,res,next) { // // Handle/reject the request, or pass it on to the http in node by calling next(); // // Optionally skip our rawBodyParser by setting this to true; // //req.skipRawBodyParser = true; // next(); // }, // httpStatic: '/home/nol/node-red-static/', //single static source /* OR multiple static sources can be created using an array of objects... */ // httpStatic: [ // {path: '/home/nol/pics/', root: "/img/"}, // {path: '/home/nol/reports/', root: "/doc/"}, // ], // httpStaticRoot: '/static/', ``` -------------------------------- ### Node-RED Configuration Object Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedOtherNodeRedContent.txt This snippet shows a JavaScript object containing various configuration options for Node-RED. Many options are commented out, indicating they are optional or have default values. ```javascript { // nodeMessageBufferMaxLength: 0, // ui: { path: "ui" }, // debugUseColors: true, debugMaxLength: 1000, // execMaxBufferSize: 10000000, // httpRequestTimeout: 120000, mqttReconnectTime: 15000, serialReconnectTime: 15000, // socketReconnectTime: 10000, // socketTimeout: 120000, // tcpMsgQueueSize: 2000, // inboundWebSocketTimeout: 5000, // tlsConfigDisableLocalFiles: true, // webSocketNodeVerifyClient: function(info) { // /** 'info' has three properties: // * - origin : the value in the Origin header // * - req : the HTTP request // * - secure : true if req.connection.authorized or req.connection.encrypted is set // * // * The function should return true if the connection should be accepted, false otherwise. // * // * Alternatively, if this function is defined to accept a second argument, callback, // * it can be used to verify the client asynchronously. // * The callback takes three arguments: // * - result : boolean, whether to accept the connection or not // * - code : if result is false, the HTTP error status to return // * - reason: if result is false, the HTTP reason string to return // */ // }, }; ``` -------------------------------- ### Nuki HTTP Handler Initialization Source: https://github.com/gladysassistant/gladys/blob/master/server/services/nuki/README.md Initialization of the NukiHTTPHandler, which depends on the NukiHandler. ```javascript const nukiHTTPHandler = new NukiHTTPHandler(nukiHandler); ``` -------------------------------- ### HTTP Node Middleware Source: https://github.com/gladysassistant/gladys/blob/master/server/services/node-red/docker/settings.txt Allows adding custom middleware for all HTTP In nodes, useful for common request processing or authentication. ```javascript /** * The following property can be used to add a custom middleware function * in front of all http in nodes. This allows custom authentication to be * applied to all http in nodes, or any other sort of common request processing. * It can be a single function or an array of middleware functions. */ // httpNodeMiddleware: function(req,res,next) { // // Handle/reject the request, or pass it on to the http in node by calling next(); // // Optionally skip our rawBodyParser by setting this to true; // //req.skipRawBodyParser = true; // next(); // }, ``` -------------------------------- ### FreeBSD Unload Kernel Module Source: https://github.com/gladysassistant/gladys/blob/master/server/services/bluetooth/README.md Command to unload the 'ng_ubt' kernel module if it is already loaded on FreeBSD. ```bash sudo kldunload ng_ubt ``` -------------------------------- ### HTTP Node Root and CORS Source: https://github.com/gladysassistant/gladys/blob/master/server/services/node-red/docker/settings.txt Configuration for the root path of HTTP nodes and Cross-Origin Resource Sharing (CORS) settings. ```javascript /** * Some nodes, such as HTTP In, can be used to listen for incoming http requests. * By default, these are served relative to '/'. The following property * can be used to specifiy a different root path. If set to false, this is * disabled. */ // httpNodeRoot: '/red-nodes', /** * The following property can be used to configure cross-origin resource sharing * in the HTTP nodes. * See https://github.com/troygoode/node-cors#configuration-options for * details on its contents. The following is a basic permissive set of options: */ // httpNodeCors: { // origin: "*", // methods: "GET,PUT,POST,DELETE" // }, ``` -------------------------------- ### HTTP Node Root Configuration Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedDefaultContent.txt Defines the root path for nodes that listen for incoming HTTP requests. If set to false, this is disabled. ```javascript // httpNodeRoot: '/red-nodes', ``` -------------------------------- ### Default Node-RED Settings Source: https://github.com/gladysassistant/gladys/blob/master/server/test/services/node-red/expectedOtherNodeRedContent.txt This is the default settings file provided by Node-RED, which can contain any valid JavaScript code. ```javascript /** * This is the default settings file provided by Node-RED. * * It can contain any valid JavaScript code that will get run when Node-RED * is started. * * Lines that start with // are commented out. * Each entry should be separated from the entries above and below by a comma ",". * * For more information about individual settings, refer to the documentation: * https://nodered.org/docs/user-guide/runtime/configuration. * * The settings are split into the following sections: * - Flow File and User Directory Settings * - Security * - Server Settings * - Runtime Settings * - Editor Settings * - Node Settings. * */ module.exports = { /** * *****************************************************************************. * Flow File and User Directory Settings * - flowFile * - credentialSecret * - flowFilePretty * - userDir * - nodesDir *****************************************************************************. */ /** The file containing the flows. If not set, defaults to flows_.json */ flowFile: 'flows.json', /** * By default, credentials are encrypted in storage using a generated key. To * specify your own secret, set the following property. * If you want to disable encryption of credentials, set this property to false. * Note: once you set this property, do not change it - doing so will prevent * node-red from being able to decrypt your existing credentials and they will be * lost. */ // credentialSecret: "a-secret-key", /** * By default, the flow JSON will be formatted over multiple lines making * it easier to compare changes when using version control. * To disable pretty-printing of the JSON set the following property to false. */ flowFilePretty: true, /** * By default, all user data is stored in a directory called `.node-red` under * the user's home directory. To use a different location, the following * property can be used. */ // userDir: '/home/nol/.node-red/', /** * Node-RED scans the `nodes` directory in the userDir to find local node files. * The following property can be used to specify an additional directory to scan. */ // nodesDir: '/home/nol/.node-red/nodes', /** * *****************************************************************************. * Security * - adminAuth * - https * - httpsRefreshInterval * - requireHttps * - httpNodeAuth * - httpStaticAuth *****************************************************************************. */ /** * To password protect the Node-RED editor and admin API, the following * property can be used. See http://nodered.org/docs/security.html for details. */ adminAuth: { type: 'credentials', users: [{ username: 'other-username', password: 'other-password', permissions: '*' }] }, /** * The following property can be used to enable HTTPS * This property can be either an object, containing both a (private) key * and a (public) certificate, or a function that returns such an object. * See http://nodejs.org/api/https.html#https_https_createserver_options_requestlistener * for details of its contents. */ /** Option 1: static object */ // https: { // key: require("fs").readFileSync('privkey.pem'), // cert: require("fs").readFileSync('cert.pem') // }, /** Option 2: function that returns the HTTP configuration object */ // https: function() { // // This function should return the options object, or a Promise // // that resolves to the options object // return { // key: require("fs").readFileSync('privkey.pem'), // cert: require("fs").readFileSync('cert.pem') // } // }, /** * If the `https` setting is a function, the following setting can be used * to set how often, in hours, the function will be called. That can be used * to refresh any certificates. */ // httpsRefreshInterval : 12, /** * The following property can be used to cause insecure HTTP connections to * be redirected to HTTPS. */ // requireHttps: true, /** * To password protect the node-defined HTTP endpoints (httpNodeRoot), * including node-red-dashboard, or the static content (httpStatic), the * following properties can be used. * The `pass` field is a bcrypt hash of the password. * See http://nodered.org/docs/security.html#generating-the-password-hash. */ // httpNodeAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."}, // httpStaticAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."}, /** * *****************************************************************************. * Server Settings * - uiPort * - uiHost * - apiMaxLength ```