blob: 2735e0da2b2b1ee3952cbc7eb8c885edbbdc415e [file] [log] [blame]
Chinthakayala, Sheshashailavas (sc2914)d1569972017-08-28 05:25:46 -09001/**
2 * Copyright 2013 IBM Corp.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 **/
16
17var server = require("./server");
18var nodes = require("./nodes");
19var library = require("./library");
20var comms = require("./comms");
21var log = require("./log");
22var util = require("./util");
23var fs = require("fs");
24var settings = require("./settings");
25var credentials = require("./nodes/credentials");
26
27var path = require('path');
28
29process.env.NODE_RED_HOME = process.env.NODE_RED_HOME || path.resolve(__dirname+"/..");
30
31var events = require("events");
32
33var RED = {
34
35 init: function(httpServer,userSettings) {
36 userSettings.version = this.version();
37 settings.init(userSettings);
38 server.init(httpServer,settings);
39 library.init();
40 return server.app;
41 },
42
43 start: server.start,
44 stop: server.stop,
45 nodes: nodes,
46 library: library,
47 credentials: credentials,
48 events: events,
49 log: log,
50 comms: comms,
51 settings:settings,
52 util: util,
53 version: function () {
54 var p = require(path.join(process.env.NODE_RED_HOME,"package.json"));
55 if (fs.existsSync(path.join(process.env.NODE_RED_HOME,".git"))) {
56 return p.version+".git";
57 } else {
58 return p.version;
59 }
60 }
61};
62
63RED.__defineGetter__("app", function() { console.log("Deprecated use of RED.app - use RED.httpAdmin instead"); return server.app });
64RED.__defineGetter__("httpAdmin", function() { return server.app });
65RED.__defineGetter__("httpNode", function() { return server.nodeApp });
66RED.__defineGetter__("server", function() { return server.server });
67
68module.exports = RED;