Skip to content

Instantly share code, notes, and snippets.

@tzamora
Last active August 29, 2015 14:05
Show Gist options
  • Save tzamora/df958ca0ffac77f665e6 to your computer and use it in GitHub Desktop.
Save tzamora/df958ca0ffac77f665e6 to your computer and use it in GitHub Desktop.
//
// Remove all env references in the server.js file
// So change the original file from this:
//
var http = require('http');
var connect = require('connect');
var colors = require('colors');
module.exports = function (debug) {
debug || (debug = env.DEBUG);
var app = connect()
.use(connect.favicon())
.use(connect.logger('dev'))
.use(connect.static('src'))
.use(connect.directory('src'))
.use(connect.cookieParser())
.use(connect.session({ secret: 'my secret here' }))
.use(function(req, res){
res.end('Hello from Connect!\n');
});
//http.createServer(app).listen(3000);
return app;
}
if (module === require.main) {
if (process.argv[2] === 'prod') env.PROD = true
module.exports().listen(env.PORT || 8000)
}
//
// to this:
//
var http = require('http');
var connect = require('connect');
var colors = require('colors');
module.exports = function (debug) {
// remove this next line
//debug || (debug = env.DEBUG);
var app = connect()
.use(connect.favicon())
.use(connect.logger('dev'))
.use(connect.static('src'))
.use(connect.directory('src'))
.use(connect.cookieParser())
.use(connect.session({ secret: 'my secret here' }))
.use(function(req, res){
res.end('Hello from Connect!\n');
});
//http.createServer(app).listen(3000);
return app;
}
if (module === require.main) {
// remove this next line
//if (process.argv[2] === 'prod') env.PROD = true
module.exports().listen(8000) // remove the env option !!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment