-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.js
51 lines (37 loc) · 1.02 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const http = require('http')
const path = require('path')
const express = require('express')
const RED = require('node-red')
const app = express()
const server = http.createServer(app)
const moment = require("moment")
const settings = {
httpAdminRoot: '/',
httpNodeRoot: '/', // /api
userDir: './',
flowFile: 'flows.json',
apiMaxLength: '50mb',
editorTheme: {
page: {
css: path.join(__dirname, "/ui-styles/midnight.css"),
scripts: path.join(__dirname, "/ui-styles/theme-tomorrow.js")
},
palette: {
editable: false
}
},
functionGlobalContext: { // enables global context
"testValue": "exampleString",
"testPackage": moment
}
}
function startNR(settings) {
console.log(`[INFO] Global settings for Node-Red: ${JSON.stringify(settings.functionGlobalContext)}`)
const port = 8000
RED.init(server, settings)
app.use(settings.httpAdminRoot, RED.httpAdmin)
app.use(settings.httpNodeRoot, RED.httpNode)
server.listen(port)
RED.start()
}
startNR(settings)