<commit_before>var express = require('express');
var bodyParser = require('body-parser');
var app = express();

app.set('port', (process.env.PORT || 3000));

app.use(bodyParser.json());
app.use(express.static(__dirname  +'/../client'));

app.set('views',__dirname + '/../client');
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');

// Should be refactored to go under /api
// Also, probably, to be rehandled in an external routehandler/ctrlrs

app.get('/locations', function(req, res) {
  res.send('locations go here');
});

app.post('/locations', function(req, res) {
  res.send('something something');
});

app.listen(app.get('port'));
console.log('Server is now listening at port ' + app.get('port'));<commit_msg>Verify mongo works with new schema and on Heroku, add db post testing path<commit_after>var express = require('express');
var bodyParser = require('body-parser');
var app = express();

var mongoose = require('mongoose');

// To use on Heroku, set the environment variable:
// $ heroku set:config MONGOLAB_URL=mongodb://user:password@mongolabstuff
var db = (process.env.MONGOLAB_URL || 'mongodb://localhost/ambits');

mongoose.connect(db);
var Location = require('./locations/locationSchema');


app.use(bodyParser.json());
app.use(express.static(__dirname  +'/../client'));

app.set('views',__dirname + '/../client');
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');

// Should be refactored to go under /api
// Also, probably, to be rehandled in an external routehandler/ctrlrs
app.get('/locations', function(req, res) {
  res.send('locations go here');
});

app.post('/locations', function(req, res) {
  res.send('something something');
});

// DB testing paths; remove when endpoints are built
app.get('/db_post', function(req, res, next) {
  var elapsed = Math.floor(Math.random()*100000);
  var newLocation = new Location({
    name: '<NAME>',
    geodata: elapsed
  });
  newLocation.save().then(function(newLocation) {
    console.log('POSTED: ', newLocation);
    res.json(newLocation);
  }).catch(function(err) {
    next(err);
  });
  
});

app.get('/db', function(req, res, next) {
  Location.find().then(function(locations) {
    res.json(locations);
  })
  .catch(function(err) {
    next(err);
  })
});

// To use on Heroku, must use port provided by process.env:
var port = (process.env.PORT || 3000);
app.listen(port);
console.log('Server is now listening at port ' + port);
{'fraction_non_alphanumeric': 0.18661257606490872, 'fraction_numerical': 0.005679513184584178, 'mean_word_length': 4.734883720930233, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6389893', 'n_tokens_mistral': 808, 'n_tokens_neox': 781, 'n_words': 196}