Chinthakayala, Sheshashailavas (sc2914) | d156997 | 2017-08-28 05:25:46 -0900 | [diff] [blame] | 1 | /** |
| 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 | |
| 17 | var server = require("./server"); |
| 18 | var nodes = require("./nodes"); |
| 19 | var library = require("./library"); |
| 20 | var comms = require("./comms"); |
| 21 | var log = require("./log"); |
| 22 | var util = require("./util"); |
| 23 | var fs = require("fs"); |
| 24 | var settings = require("./settings"); |
| 25 | var credentials = require("./nodes/credentials"); |
| 26 | |
| 27 | var path = require('path'); |
| 28 | |
| 29 | process.env.NODE_RED_HOME = process.env.NODE_RED_HOME || path.resolve(__dirname+"/.."); |
| 30 | |
| 31 | var events = require("events"); |
| 32 | |
| 33 | var 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 | |
| 63 | RED.__defineGetter__("app", function() { console.log("Deprecated use of RED.app - use RED.httpAdmin instead"); return server.app }); |
| 64 | RED.__defineGetter__("httpAdmin", function() { return server.app }); |
| 65 | RED.__defineGetter__("httpNode", function() { return server.nodeApp }); |
| 66 | RED.__defineGetter__("server", function() { return server.server }); |
| 67 | |
| 68 | module.exports = RED; |