windhamdavid 3 years ago
parent
commit
65255fcfb7
3 changed files with 52 additions and 18 deletions
  1. 19 11
      app.js
  2. 23 0
      config.js
  3. 10 7
      package.json

+ 19 - 11
app.js

@@ -1,21 +1,29 @@
-var build = require('./build');
 var express = require('express');
-var app = express();
+var bodyParser = require('body-parser');
+var events = require('events');
+var http = require('http');
+var path = require('path');
+
 
-//var config = require('./config.json')[process.env.NODE_ENV || 'development'];
 
-var env = process.env.NODE_ENV || 'development';
-if ('development' == env) {
-   //Changed for Express 4
-}
+var app = express();
 
+var config = {
+  development: require('./config-dev.js'),
+  production: require('./config.js')
+};
 
+var app = express(),
+    server = http.createServer(app);
+    server.listen(conf.port);
 
-app.use(express.static(__dirname + '/build'));
+app.use(bodyParser.json());
+app.use(bodyParser.urlencoded({ extended: false }));
+app.use(express.static(path.join(__dirname, 'app')));
 
-var port = process.env.PORT || 3000;
 
-app.listen(process.env.PORT, function(){
-  console.log('running at http://localhost:' + process.env.PORT + '');
+var logger = new events.EventEmitter();
+logger.on('newEvent', function(event, data) {
+  console.log('%s: %s', event, JSON.stringify(data));
 });
 

+ 23 - 0
config.js

@@ -0,0 +1,23 @@
+var config = {
+  //REDISURL: getEnv('REDISURL'),
+  //PORT: getEnv('PORT'),
+  //FBID: getEnv('FBID'),
+  //FBIDSECRET: getEnv('FBIDSECRET')
+};
+
+conf = {
+    port: 3000,
+    debug: false,
+    dbPort: 6379,
+    dbHost: '127.0.0.1',
+    dbOptions: {}
+};
+
+function getEnv(variable){
+  if (process.env[variable] === undefined){
+    throw new Error('You must create an environment variable for ' + variable);
+  }
+  return process.env[variable];
+};
+
+module.exports = config;

+ 10 - 7
package.json

@@ -5,11 +5,6 @@
   "homepage": "http://juryd.com",
   "author": "David A. Windham",
   "private": true,
-  "scripts": {
-    "gulp": "gulp",
-    "build": "node build.js",
-    "serve": "node build.js serve"
-  },
   "repository": {
     "type": "git",
     "url": "git+https://github.com/windhamdavid/juryd.git"
@@ -18,7 +13,15 @@
     "node": ">=4.0.0"
   },
   "dependencies": {
-    "gulp": "^3.9.0",
-    "express": "^4.13.3"
+    "express": "^4.13.3",
+    "body-parser": "^1.14.1",
+    "cookie-parser": "~1.3.5",
+    "serve-favicon": "~2.3.0"
+  },
+  "devDependencies": {
+    "gulp": "^3.9.0"
+  },
+    "scripts": {
+    "start": "node app.js"
   }
 }