Permalink
Browse files

#14 Use NODE env to configure node server/client

  • Loading branch information...
1 parent 39c6da8 commit 3f3ce27d9cb861a642bf8fc018e8c9ab64645b84 Nisheeth Kashyap committed Sep 6, 2013
View
@@ -88,7 +88,6 @@ window.ConsoleIO.config = {
// optionals
secure: false,
- minify: true,
nativeConsole: true,
web: false, // true to display web console
@@ -126,7 +125,6 @@ define(['console.io'], function (consoleio) {
// optionals
secure: false,
- minify: true,
nativeConsole: true,
web: false,
View
@@ -1 +1 @@
-grunt default > debug-log.txt
+grunt default > build-log.txt
View
@@ -1,11 +1,11 @@
/**
* Name: console.io
- * Version: 0.2.0
+ * Version: 0.2.0-1
* Description: Javascript Remote Web Console
* Website: http://nkashyap.github.io/console.io/
* Author: Nisheeth Kashyap
* Email: nisheeth.k.kashyap@gmail.com
- * Date: 2013-09-04
+ * Date: 2013-09-06
*/
code {
View
@@ -1,11 +1,11 @@
/**
* Name: console.io
- * Version: 0.2.0
+ * Version: 0.2.0-1
* Description: Javascript Remote Web Console
* Website: http://nkashyap.github.io/console.io/
* Author: Nisheeth Kashyap
* Email: nisheeth.k.kashyap@gmail.com
- * Date: 2013-09-04
+ * Date: 2013-09-06
*/
/**

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,15 +1,15 @@
/**
* Name: console.io
- * Version: 0.2.0
+ * Version: 0.2.0-1
* Description: Javascript Remote Web Console
* Website: http://nkashyap.github.io/console.io/
* Author: Nisheeth Kashyap
* Email: nisheeth.k.kashyap@gmail.com
- * Date: 2013-09-04
+ * Date: 2013-09-06
*/
var ConsoleIO = ("undefined" === typeof module ? {} : module.exports);
-ConsoleIO.version = "0.2.0";
+ConsoleIO.version = "0.2.0-1";
(function(){
@@ -364,7 +364,7 @@ ConsoleIO.version = "0.2.0";
return styleNode.join("; ");
};
- util.getUrl = function getUrl(name, uncompressed) {
+ util.getUrl = function getUrl(name) {
var config = exports.getConfig(),
url = config.url,
last = url.length - 1,
@@ -374,11 +374,6 @@ ConsoleIO.version = "0.2.0";
url = url.substr(0, last);
}
- if (config.minify && !uncompressed) {
- fileUrl = fileUrl.replace('.css', '.min.css');
- fileUrl = fileUrl.replace('.js', '.min.js');
- }
-
url += (config.base.length > 0 ? '/' + config.base : '/') + fileUrl;
return url;
@@ -2046,7 +2041,6 @@ ConsoleIO.version = "0.2.0";
url: '',
base: '',
secure: false,
- minify: true,
html2canvas: "plugins/html2canvas.js",
//"console.io": "console.io.js",
@@ -2123,7 +2117,7 @@ ConsoleIO.version = "0.2.0";
if (exports.util.foundRequireJS()) {
global.require(["socket.io"], setUp);
} else {
- exports.util.require(exports.util.getUrl("socket.io", true), setUp);
+ exports.util.require(exports.util.getUrl("socket.io"), setUp);
}
}
} else {

Large diffs are not rendered by default.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,6 +1,6 @@
{
"name": "xconsole.io",
- "version": "0.2.0",
+ "version": "0.2.0-1",
"project": "console.io",
"subdomain": "console.io",
"description": "Javascript Remote Web Console",
View
@@ -30,7 +30,7 @@
var config = {
- domain: null, //'.bbdev1.com',
+ domain: null,
/** express configurations **/
express: {
View
@@ -19,31 +19,57 @@ function main() {
fs = require('fs'),
manager = require('./manager');
-
function Workers() {
var app,
base = '/',
opts = {};
- if (config.https.enable) {
- if (config.https.pfx) {
- opts.pfx = fs.readFileSync(config.https.pfx);
+ function getApp(config) {
+ var expressApp;
+ if (!config.https.enable) {
+ expressApp = express().http().io();
} else {
- opts.key = fs.readFileSync(config.https.key);
- opts.cert = fs.readFileSync(config.https.certificate);
- // This is necessary only if the client uses the self-signed certificate.
- if (config.https.ca) {
- opts.ca = fs.readFileSync(config.https.ca);
+ if (config.https.pfx) {
+ opts.pfx = fs.readFileSync(config.https.pfx);
+ } else {
+ opts.key = fs.readFileSync(config.https.key);
+ opts.cert = fs.readFileSync(config.https.certificate);
+ // This is necessary only if the client uses the self-signed certificate.
+ if (config.https.ca) {
+ opts.ca = fs.readFileSync(config.https.ca);
+ }
+ }
+
+ if (opts.requestCert) {
+ opts.requestCert = config.https.requestCert;
}
+
+ expressApp = express().https(opts).io();
}
- if (opts.requestCert) {
- opts.requestCert = config.https.requestCert;
+ return expressApp;
+ }
+
+ function getURL(url, base) {
+ url = url.replace(base, '/');
+
+ if (process.env.NODE_ENV === 'production') {
+ url = url.replace('.js', '.min.js');
+ url = url.replace('.css', '.min.css');
}
- app = express().https(opts).io();
- } else {
- app = express().http().io();
+ return url;
+ }
+
+
+ //if node env is not defined then set it to 'production'
+ if (!process.env.NODE_ENV) {
+ process.env.NODE_ENV = 'production';
+ }
+
+ //if env port no is not define then use one defined in config
+ if (!process.env.PORT) {
+ process.env.PORT = app.get('port-number');
}
// If this node.js application is hosted in IIS, assume it is hosted
@@ -56,13 +82,16 @@ function main() {
config.io.development.set.push({ 'resource': base + 'socket.io' });
config.io.production.set.push({ 'resource': base + 'socket.io' });
+
+ //get expressjs app
+ app = getApp(config);
+
// configuration
configure(app, 'development', config.express);
configure(app, 'production', config.express);
configure(app.io, 'development', config.io);
configure(app.io, 'production', config.io);
-
// Setup your sessions, just like normal.
app.use(base, express.cookieParser());
app.use(base, express.session({ secret: app.get('session-key') }));
@@ -82,15 +111,12 @@ function main() {
//console client routes
function client(req, res) {
- res.sendfile('./dist/client' + req.originalUrl.replace(base, '/'));
+ res.sendfile('./dist/client' + getURL(req.originalUrl, base));
}
app.use(base + 'console.io.js', client);
- app.use(base + 'console.io.min.js', client);
app.use(base + 'console.css', client);
- app.use(base + 'console.min.css', client);
app.use(base + 'plugins/html2canvas.js', client);
- app.use(base + 'plugins/html2canvas.min.js', client);
//userdata app routes
app.use(base + 'userdata/export', function download(req, res) {
@@ -104,14 +130,14 @@ function main() {
//console app routes
app.use(base, function app(req, res) {
- res.sendfile('./dist/app' + req.originalUrl.replace(base, '/'));
+ res.sendfile('./dist/app' + getURL(req.originalUrl, base));
});
// initialize connection manager
manager.setUp(app);
// listen to port
- app.listen(process.env.PORT || app.get('port-number'));
+ app.listen(process.env.PORT);
//set GUID cookie handler
(function setUpCookieHandler(express, app) {
@@ -237,7 +263,7 @@ function main() {
}(express, app));
//display remote ui url information
- console.log(app.get('title') + ' is run at ' + (config.https.enable ? 'https' : 'http') + '://localhost:' + (process.env.PORT || app.get('port-number')));
+ console.log(app.get('title') + ' is run at ' + (config.https.enable ? 'https' : 'http') + '://localhost:' + process.env.PORT);
}
Workers();
View
@@ -15,7 +15,6 @@
url: '',
base: '',
secure: false,
- minify: true,
html2canvas: "plugins/html2canvas.js",
//"console.io": "console.io.js",
@@ -92,7 +91,7 @@
if (exports.util.foundRequireJS()) {
global.require(["socket.io"], setUp);
} else {
- exports.util.require(exports.util.getUrl("socket.io", true), setUp);
+ exports.util.require(exports.util.getUrl("socket.io"), setUp);
}
}
} else {
View
@@ -349,7 +349,7 @@
return styleNode.join("; ");
};
- util.getUrl = function getUrl(name, uncompressed) {
+ util.getUrl = function getUrl(name) {
var config = exports.getConfig(),
url = config.url,
last = url.length - 1,
@@ -359,11 +359,6 @@
url = url.substr(0, last);
}
- if (config.minify && !uncompressed) {
- fileUrl = fileUrl.replace('.css', '.min.css');
- fileUrl = fileUrl.replace('.js', '.min.js');
- }
-
url += (config.base.length > 0 ? '/' + config.base : '/') + fileUrl;
return url;

0 comments on commit 3f3ce27

Please sign in to comment.