Skip to content

Commit

Permalink
Add basic server configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-oakes committed Sep 21, 2015
1 parent 6891d04 commit e2273de
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHECKS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: node app.js
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"

config.vm.network "forwarded_port", guest: 3000, host: 3000
config.vm.network "forwarded_port", guest: 4568, host: 4568

config.vm.synced_folder "./", "/home/vagrant/app"

Expand Down
32 changes: 31 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
console.log("Hello world!");
// External dependencies
var express = require( 'express' );


// Dependencies
var environment = require( './app/lib/environment' );


// Local variables
var app = express();


/**
* Initialise
*/
var init = function init() {

app.get( '/', function ( req, res ) {
res.send( 'Hello World!' );
} );

var server = app.listen( environment.port, function () {
console.log( 'Example app listening at %s', environment.baseUrl );
} );

console.log( environment );

};

// Get the party started
init();
20 changes: 20 additions & 0 deletions app/lib/environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// External dependencies
var dotenv = require( 'dotenv' );

// Local variables
var environmentName = process.env.NODE_ENV || process.env.node_env || 'development';

// Use .env file for development and test
if ( environmentName === 'development' || environmentName === 'test' ) {
dotenv.load();
}

var environment = {
project: 'ribot API',
name: environmentName,
baseUrl: process.env.BASE_URL,
port: process.env.PORT
};

// Exports
module.exports = environment;
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"author": "",
"license": "ISC",
"engines": {
"node" : "0.10.26"
"node": "0.10.26"
},
"dependencies": {
"dotenv": "^1.2.0",
"express": "^4.13.3"
}
}

0 comments on commit e2273de

Please sign in to comment.