-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
68 lines (57 loc) · 1.75 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var lvcap = require('lv-cap');
var OAuth = require('oauth');
var app = require('./openLV/index.js');
//dev @ 0.0.6 prod @ 1.0.0
var env = 'prod';//'prod';
var options = {
containerId: 'imconsulting_node-red_00',
keyPath: './' + env + '/imconsulting_node-red.key',
certPath: './' + env + '/imconsulting_node-red.crt',
rejectUnauthorized: false,//true,
debug: true
};
var started = false;
var configurationCB = function (config) {
if (started) {
lvcap.setStatus('RESTART');
}
else {
var flows = config.flows || [];
var settings = {
httpAdminRoot: config.adminRoot ? config.adminRoot.toString() : false,
adminAuth: {
type: 'credentials',
users: [{
username: 'admin',
password: '$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN.',
permissions: '*'
}]
},
httpNodeRoot: config.nodeRoot ? config.nodeRoot.toString() : "/",
ui: { path: config.dash ? config.dash.toString() : "dash" },
functionGlobalContext: {
lvcapPub: lvcap.publish,
lvcapSub: lvcap.subscribe,
lvcapUnsub: lvcap.unsubscribe,
}
};
if (config.adminAuth && Array.isArray(config.adminAuth)) {
settings.adminAuth.users = config.adminAuth;
}
var httpAuth = {
user: 'user',
pass: '$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN.'
};
if (config.auth) {
if (config.auth.username) httpAuth.user = config.auth.username.toString();
if (config.auth.password) httpAuth.pass = config.auth.password.toString();
}
app.start(settings, httpAuth, flows);
started = true;
}
};
var shutdownCB = function () {
app.nodes.setFlows([]);
app.stop();
};
lvcap.start(options, configurationCB, shutdownCB);