<commit_before>var express = require('express');
var router = express.Router();
var config_reader = require('yaml-config');
// Read in the configuration files that we have
var config_db = config_reader.readConfig('../config/database.yml');

// Set the globals that are required
mongoose = require('mongoose');
var resourceSchema = mongoose.Schema({name: String, counter: Number});
var resourceModel = mongoose.model('resource', resourceSchema);

// Connect Mongoose to the db already
console.log( __dirname );
mongoose.connect("mongodb://"+ process.env.DB_USER + ":" + process.env.DB_PW + "@" + config_db.mongo.uri);

function getResourceList(req, res) {
	resourceModel.find().lean().exec(function (err, resourcelist) {
		//console.log(JSON.stringify(resourcelist));
		res.render('resources', {title: 'Resources', resources: JSON.parse(JSON.stringify(resourcelist))});
	});
}

/* GET resources listing. */
router.get('/', function(req, res, next) {
	//db.once('open', function (callback) {
		getResourceList(req, res)
	//});
});

router.get('/new', function(req, res, next) {
  res.render('newresource', {title: 'New Resource'})
}); 

router.post('/', function(req,res){
	//db.once('open', function (callback) {
		var newresource = new resourceModel({ name: req.body.name, counter: req.body.counter });
		newresource.save(function (err) {
			if (err) {
		  		res.writeHead(500, {'content-type': 'text/plain'});
		    	res.end('An error occurred');
			};
		});
		getResourceList(req, res)
	//});
});

module.exports = router;
<commit_msg>To hell with it, using a single env var now instead of config files<commit_after>var express = require('express');
var router = express.Router();
var config_reader = require('yaml-config');
// Read in the configuration files that we have
//var config_db = config_reader.readConfig('../config/database.yml');

// Set the globals that are required
mongoose = require('mongoose');
var resourceSchema = mongoose.Schema({name: String, counter: Number});
var resourceModel = mongoose.model('resource', resourceSchema);

// Connect Mongoose to the db already
mongoose.connect(process.env.MONGOLAB_URI);

function getResourceList(req, res) {
	resourceModel.find().lean().exec(function (err, resourcelist) {
		//console.log(JSON.stringify(resourcelist));
		res.render('resources', {title: 'Resources', resources: JSON.parse(JSON.stringify(resourcelist))});
	});
}

/* GET resources listing. */
router.get('/', function(req, res, next) {
	//db.once('open', function (callback) {
		getResourceList(req, res)
	//});
});

router.get('/new', function(req, res, next) {
  res.render('newresource', {title: 'New Resource'})
}); 

router.post('/', function(req,res){
	//db.once('open', function (callback) {
		var newresource = new resourceModel({ name: req.body.name, counter: req.body.counter });
		newresource.save(function (err) {
			if (err) {
		  		res.writeHead(500, {'content-type': 'text/plain'});
		    	res.end('An error occurred');
			};
		});
		getResourceList(req, res)
	//});
});

module.exports = router;

{'fraction_non_alphanumeric': 0.1798750411048997, 'fraction_numerical': 0.0019730351857941467, 'mean_word_length': 4.816443594646271, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, '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': '4850562', 'n_tokens_mistral': 994, 'n_tokens_neox': 965, 'n_words': 226}