<commit_before>/// <reference path="../typings/tsd.d.ts" />
var express = require('express');
var mongoose = require('mongoose');
var Home = require('../models/Home');
var router = express.Router();
/* GET homes page. */
router.get('/', function (req, res) {
	res.render('homes');
});
router.get('/data', function (req, res) {
	var page = req.query['page'];
	var max = req.query['max'];
	var sidx = req.query['sidx'];
	var order = req.query['sord'];
	var sort = {};
	if (sidx && sidx !== '') {
		sort[sidx] = order;
	}
	Home.count(function (err, total) {
		if (!err) {
			Home.find({}).sort(sort).limit(max).skip((page - 1) * max).exec(function (err, homes) {
				if (!err) {
					var result = {
						rows: homes,
						page: page,
						max: max,
						total: total
					};
					res.json(result);
				}
				else {
					res.status(500).end();
				}
			});
		}
		else {
			res.status(500).end();
		}
	});
});
router.post('/data', function (req, res) {
	var data = req.body;
	var request_type = data['oper'];

	delete data['oper'];
	delete data['id'];

	if (request_type === 'add') {
		var id = mongoose.Types.ObjectId();
		var home = new Home(data);
		home["_id"] = id;
		home.save(function (err, result) {
			console.log(result);
			if (!err) {
				res.status(201).end();
			}
			else {
				res.status(500).end();
			}
		});
	}
	else {
		var _id = data['_id'];
		delete data['_id'];

		if (request_type === 'edit') {

			Home.update({_id:_id}, data, {}, function(err, result) {
				console.log(result);
				if (!err) {
					res.status(200).end();
				}
				else {
					res.status(500).end();
				}
			});
		} else {
			if(request_type === 'del'){
				console.log(_id);
				Home.remove({_id : _id}, function(err, result){
					if (!err) {
						res.status(200).end();
					}
					else {
						res.status(500).end();
					}
				});
			}
		}
	}
});
module.exports = router;
//# sourceMappingURL=homes.js.map
<commit_msg>Set routes/homes.ts up for ES6<commit_after>/// <reference path="../typings/tsd.d.ts" />
import express = require('express');
import mongoose = require('mongoose');
import Home = require('../models/Home');

var router = express.Router();
/* GET homes page. */
router.get('/', (req, res) => {
	res.render('homes');
});

router.get('/data', (req, res) => {
	var page = req.query['page'];
	var max = req.query['max'];
	var sidx = req.query['sidx'];
	var order = req.query['sord'];
	var sort = {};
	if (sidx && sidx !== '') {
		sort[sidx] = order;
	}
	Home.count((err, total) => {
		if (!err) {
			Home.find({}).sort(sort).limit(max).skip((page - 1) * max).exec((err, homes) => {
				if (!err) {
					var result = {
						rows: homes,
						page: page,
						max: max,
						total: total
					};
					res.json(result);
				}
				else {
					res.status(500).end();
				}
			});
		}
		else {
			res.status(500).end();
		}
	});
});

router.post('/data', (req, res) => {
	var data = req.body;
	var request_type = data['oper'];

	delete data['oper'];
	delete data['id'];

	if (request_type === 'add') {
		var id = new mongoose.Types.ObjectId();
		var home = new Home(data);
		home["_id"] = id;
		home.save((err, result) => {
			console.log(result);
			if (!err) {
				res.status(201).end();
			}
			else {
				res.status(500).end();
			}
		});
	}
	else {
		var _id = data['_id'];
		delete data['_id'];

		if (request_type === 'edit') {

			Home.update({_id: _id}, data, {}, (err, result) => {
				console.log(result);
				if (!err) {
					res.status(200).end();
				}
				else {
					res.status(500).end();
				}
			});
		} else {
			if (request_type === 'del') {
				console.log(_id);
				Home.remove({_id: _id}, (err, result) => {
					if (!err) {
						res.status(200).end();
					}
					else {
						res.status(500).end();
					}
				});
			}
		}
	}
});
export = router;

{'fraction_non_alphanumeric': 0.22542283298097252, 'fraction_numerical': 0.013477801268498943, 'mean_word_length': 2.6013320647002853, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '2433568', 'n_tokens_mistral': 1759, 'n_tokens_neox': 1418, 'n_words': 286}