├── .gitignore ├── README.md ├── nodes ├── lower-case.js └── lower-case.html ├── package.json └── app.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | manifest.yml 3 | 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Node-RED wrapper app to allow that adds port customization.# Node-RED-OpenShift sample OpenShift App 2 | -------------------------------------------------------------------------------- /nodes/lower-case.js: -------------------------------------------------------------------------------- 1 | module.exports = function(RED) { 2 | function LowerCaseNode(config) { 3 | console.log("VBBBAAA!!!") 4 | RED.nodes.createNode(this,config); 5 | var node = this; 6 | this.on('input', function(msg) { 7 | msg.payload = msg.payload.toLowerCase(); 8 | node.send(msg); 9 | }); 10 | } 11 | RED.nodes.registerType("lower-case",LowerCaseNode); 12 | } 13 | -------------------------------------------------------------------------------- /nodes/lower-case.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 23 | 24 | 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Node-Red-OpenShift", 3 | "version": "1.0.0", 4 | "description": "Node-RED on OpenShift", 5 | "homepage": "http://nodered.org", 6 | "keywords": [ 7 | "node-red", 8 | "OpenShift", 9 | "editor", 10 | "messaging" 11 | ], 12 | "license": "Apache-2.0", 13 | "main": "lib/red.js", 14 | 15 | "engines": { 16 | "node": "*", 17 | "npm": "*" 18 | }, 19 | 20 | "dependencies": { 21 | "ajv": "6.10.0", 22 | "basic-auth": "2.0.1", 23 | "bcryptjs": "2.4.3", 24 | "body-parser": "1.19.0", 25 | "cheerio": "0.22.0", 26 | "clone": "2.1.2", 27 | "content-type": "1.0.4", 28 | "cookie": "0.4.0", 29 | "cookie-parser": "1.4.4", 30 | "cors": "2.8.5", 31 | "cron": "1.7.1", 32 | "denque": "1.4.1", 33 | "express": "4.17.1", 34 | "express-session": "1.16.2", 35 | "fs-extra": "8.1.0", 36 | "fs.notify": "0.0.4", 37 | "hash-sum": "2.0.0", 38 | "https-proxy-agent": "2.2.1", 39 | "i18next": "15.1.0", 40 | "iconv-lite": "0.5.0", 41 | "is-utf8": "0.2.1", 42 | "js-yaml": "3.13.1", 43 | "json-stringify-safe": "5.0.1", 44 | "jsonata": "1.6.5", 45 | "media-typer": "1.1.0", 46 | "memorystore": "1.6.1", 47 | "mime": "2.4.4", 48 | "mqtt": "2.18.8", 49 | "multer": "1.4.1", 50 | "mustache": "3.0.1", 51 | "node-red-node-email": "^1.6.2", 52 | "node-red-node-feedparser": "^0.1.14", 53 | "node-red-node-rbe": "^0.2.4", 54 | "node-red-node-sentiment": "^0.1.3", 55 | "node-red-node-tail": "^0.0.2", 56 | "node-red-node-twitter": "^1.1.5", 57 | "nopt": "4.0.1", 58 | "oauth2orize": "1.11.0", 59 | "on-headers": "1.0.2", 60 | "passport": "0.4.0", 61 | "passport-http-bearer": "1.0.1", 62 | "passport-oauth2-client-password": "0.1.2", 63 | "raw-body": "2.4.1", 64 | "request": "2.88.0", 65 | "semver": "6.2.0", 66 | "uglify-js": "3.6.0", 67 | "when": "3.7.8", 68 | "ws": "6.2.1", 69 | "xml2js": "0.4.19" 70 | }, 71 | "scripts": { 72 | "start": "node red.js", 73 | }, 74 | "repository": { 75 | "type": "git", 76 | "url": "https://github.com/johnwalicki/node-red-openshift.git" 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | var express = require("express"); 3 | var RED = require("node-red"); 4 | var atob = require('atob'); 5 | 6 | var MyRed = function() { 7 | 8 | // Scope. 9 | var self = this; 10 | 11 | 12 | /* ================================================================ */ 13 | /* Helper functions. */ 14 | /* ================================================================ */ 15 | 16 | /** 17 | * Set up server IP address and port # using env variables/defaults. 18 | */ 19 | self.setupVariables = function() { 20 | // Set the environment variables we need. 21 | self.ipaddress = process.env.OPENSHIFT_NODEJS_IP; 22 | self.port = process.env.OPENSHIFT_NODEJS_PORT || 8000; 23 | 24 | if (typeof self.ipaddress === "undefined") { 25 | // Log errors on OpenShift but continue w/ 127.0.0.1 - this 26 | // allows us to run/test the app locally. 27 | console.warn('No OPENSHIFT_NODEJS_IP var, using 127.0.0.1'); 28 | self.ipaddress = "127.0.0.1"; 29 | }; 30 | 31 | 32 | 33 | // Create the settings object 34 | self.redSettings = { 35 | httpAdminRoot:"/", 36 | httpNodeRoot: "/api", 37 | userDir: process.env.OPENSHIFT_DATA_DIR 38 | }; 39 | 40 | if (typeof self.redSettings.userDir === "undefined") { 41 | console.warn('No OPENSHIFT_DATA_DIR var, using ./'); 42 | self.redSettings.userDir = "./"; 43 | } 44 | }; 45 | 46 | /** 47 | * terminator === the termination handler 48 | * Terminate server on receipt of the specified signal. 49 | * @param {string} sig Signal to terminate on. 50 | */ 51 | self.terminator = function(sig){ 52 | if (typeof sig === "string") { 53 | console.log('%s: Received %s - terminating app ...', 54 | Date(Date.now()), sig); 55 | RED.stop(); 56 | process.exit(1); 57 | } 58 | console.log('%s: Node server stopped.', Date(Date.now()) ); 59 | }; 60 | 61 | /** 62 | * Setup termination handlers (for exit and a list of signals). 63 | */ 64 | self.setupTerminationHandlers = function(){ 65 | // Process on exit and signals. 66 | process.on('exit', function() { self.terminator(); }); 67 | 68 | // Removed 'SIGPIPE' from the list - bugz 852598. 69 | ['SIGHUP', 'SIGINT', 'SIGQUIT', 'SIGILL', 'SIGTRAP', 'SIGABRT', 70 | 'SIGBUS', 'SIGFPE', 'SIGUSR1', 'SIGSEGV', 'SIGUSR2', 'SIGTERM' 71 | ].forEach(function(element, index, array) { 72 | process.on(element, function() { self.terminator(element); }); 73 | }); 74 | }; 75 | 76 | /* ================================================================ */ 77 | /* App server functions (main app logic here). */ 78 | /* ================================================================ */ 79 | 80 | /** 81 | * Create the routing table entries + handlers for the application. 82 | */ 83 | self.createRoutes = function() { 84 | self.routes = { }; 85 | 86 | self.routes['/asciimo'] = function(req, res) { 87 | var link = "http://i.imgur.com/kmbjB.png"; 88 | res.send("