{"size": 1207, "ext": "js", "max_stars_repo_path": "server/app.js", "max_stars_repo_name": "chambjl/recipe-organizer", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server/app.js", "max_issues_repo_name": "chambjl/recipe-organizer", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server/app.js", "max_forks_repo_name": "chambjl/recipe-organizer", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 30.175, "max_line_length": 73, "alphanum_fraction": 0.6636288318}
var MongoClient = require('mongodb').MongoClient;
var express = require('express');
var config = require('./config/config.json');
var _ = require('lodash');
var app = express();
var reload = require('reload');
var path = require("path");

app.set('port', process.env.PORT || config.port || 3000);
app.set('mongodb.port', process.env.MONGODB_PORT ||
        (config.mongodb ? config.mongodb.port : undefined) || 27017);
app.set('mongodb.ip', process.env.MONGODB_IP ||
        (config.mongodb ? config.mongodb.ip : undefined) || 'localhost');

var database;
MongoClient.connect('mongodb://' + app.get('mongodb.ip') + ':'
    + app.get('mongodb.port') + '/recipes',function(err,db){
  if(err) throw err;
  database = db
  console.log('connected to mongoDB on port ' + app.get('mongodb.port'));
});
app.use(function(req,res,next){
  req.db = database;
  next();
});

app.use(require('./routes/recipes'));
app.use(express.static(path.join(__dirname+'/static')));
app.get('/**', function(request, response){
  response.sendFile(path.join(__dirname+'/static/index.html'));
});

var server = app.listen(app.get('port'), function(){
  console.log('Listening on port ' + app.get('port'));
});



reload(server, app);
