"use strict";

var os = require("os"),
    path = require("path"),
    express = require("express"),
    routes = require("./routes");

var app = express(),
    hostname = os.hostname(),
    port = process.env.CONPA_PORT || 8080,
    documentRoot = path.join(__dirname, "../client"),
    liveUrl = process.env.CONPA_LIVE_URL,
    testingUrl = process.env.CONPA_TEST_URL;

if (!liveUrl && !testingUrl) {
    throw new Error("CONPA_LIVE_URL and CONPA_TEST_URL not defined.");
}

process.on("uncaughtException", function (err) {
    console.log(err.stack);
});

app.get("/status", function (req, res) {
    res.send("ConPA is running on " + hostname + " on " + process.version);
});

app.use(express.static(documentRoot));

routes.configure(app, {
    crm: {
        liveDomain: hostname,
        // liveDomain: "foo.com",
        liveUrl: liveUrl,
        liveDb: "conpa",
        testingUrl: testingUrl,
        testingDb: "conpa-staging",
        design: "ConPA"
    }
});

app.listen(port, function () {
    console.log("ConPA document root is " + documentRoot);
    console.log("ConPA listening on http://" + hostname + ":" + port);
});

"use strict";

var os = require("os"),
    path = require("path"),
    express = require("express"),
    routes = require("./routes");

var app = express(),
    hostname = os.hostname(),
    port = process.env.CONPA_PORT || 8080,
    documentRoot = path.join(__dirname, "../client");

process.on("uncaughtException", function (err) {
    console.log(err.stack);
});

app.get("/status", function (req, res) {
    res.send("ConPA is running on " + hostname + " on " + process.version);
});

app.use(express.static(documentRoot));

routes.configure(app, {
    crm: {
        liveDomain: hostname,
        // liveDomain: "foo.com",
        liveUrl: process.env.CONPA_LIVE_URL,
        liveDb: "conpa",
        testingUrl: process.env.CONPA_TEST_URL,
        testingDb: "conpa-staging",
        design: "ConPA"
    }
});

app.listen(port, function () {
    console.log("ConPA document root is " + documentRoot);
    console.log("ConPA listening on http://" + hostname + ":" + port);
});

--- 
+++ 
@@ -8,7 +8,13 @@
 var app = express(),
     hostname = os.hostname(),
     port = process.env.CONPA_PORT || 8080,
-    documentRoot = path.join(__dirname, "../client");
+    documentRoot = path.join(__dirname, "../client"),
+    liveUrl = process.env.CONPA_LIVE_URL,
+    testingUrl = process.env.CONPA_TEST_URL;
+
+if (!liveUrl && !testingUrl) {
+    throw new Error("CONPA_LIVE_URL and CONPA_TEST_URL not defined.");
+}
 
 process.on("uncaughtException", function (err) {
     console.log(err.stack);
@@ -24,9 +30,9 @@
     crm: {
         liveDomain: hostname,
         // liveDomain: "foo.com",
-        liveUrl: process.env.CONPA_LIVE_URL,
+        liveUrl: liveUrl,
         liveDb: "conpa",
-        testingUrl: process.env.CONPA_TEST_URL,
+        testingUrl: testingUrl,
         testingDb: "conpa-staging",
         design: "ConPA"
     }
Throw an exception if env vars not set.
