Last active
December 23, 2015 20:49
-
-
Save shadow-fox/6692230 to your computer and use it in GitHub Desktop.
Express not recognizing environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'), | |
path = require('path'), | |
ejs = require('ejs'); | |
module.exports = function() { | |
var app = express(); | |
var publicDir = path.join(__dirname, '../public'); | |
// Store all environment variables | |
app.set('port', process.env.PORT || 3000); | |
// Basic configuration | |
app.configure(function() { | |
app.use(express.logger('dev')); | |
app.use(express.bodyParser()); | |
app.use(express.methodOverride()); | |
app.use(app.router); | |
app.use(express.static(publicDir)); | |
}); | |
// Environment specific configuration | |
require('./env')(app); | |
return app; | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'), | |
hbsPrecompiler = require('handlebars-precompiler'), | |
path = require('path'); | |
module.exports = function(app) { | |
// development compile Handlebars and show errors | |
app.configure('development', function(){ | |
app.set('db-uri', process.env.MONGOLAB_URI || 'mongodb://localhost/App'); | |
hbsPrecompiler.watchDir( | |
path.join(__dirname, "../public/templates"), | |
path.join(__dirname, "../public/templates/compiled/templates.js"), | |
['handlebars', 'hbs'] | |
); | |
app.use(express.errorHandler()); | |
}); | |
app.configure('production', function(){ | |
app.set('db-uri', process.env.MONGOLAB_URI); | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/usr/bin/node app.js | |
App is Up at 3000 as undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Module dependencies. | |
var http = require('http'), | |
app = require('./config/app')(); | |
// Start server | |
app.listen(app.get('port'), function(){ | |
console.log('App is Up at '+ app.get('port') + ' as ' + process.env.NODE_ENV); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment