<commit_before>/**
* RPTree 2014 Server: Restify server
*/

// Get link to main module
app = require.main.exports;

// Initialize Restify server
var restify = require('restify'),
server = restify.createServer(app.config.server.options);

// Load Restify middleware
server.use(restify.queryParser());
server.use(restify.CORS());

// Define REST route to retrieve tweets from Mongo (used by Backbone)
server.get('/feed', function(req, res) {
	app.config.debug && console.log("<SRV> Feed request, params = " + JSON.stringify(req.params));
	app.data.listTweets(req.params)
	.then(function(tweets) {
		res.json(tweets);
	})
	.catch(function(err) {
		app.config.debug && console.log("<SRV> !!! ERROR: ", err);
		res.status(500);
	});
});

// Create static route
server.get(/.*/, restify.serveStatic({
	directory: './www',
	default: 'index.html'
}));

// Start Restify server
server.listen(app.config.server.port, function() {
	console.log('<SRV> %s listening at %s', server.name, server.url);
});

// Export server
module.exports = server;<commit_msg>Adding tree-testing endpoint for troubleshooting<commit_after>/**
* RPTree 2014 Server: Restify server
*/

// Get link to main module
app = require.main.exports;

// Initialize Restify server
var restify = require('restify'),
server = restify.createServer(app.config.server.options);

// Load Restify middleware
server.use(restify.queryParser());
server.use(restify.CORS());

// Define REST route to retrieve tweets from Mongo (used by Backbone)
server.get('/feed', function(req, res) {
	app.config.debug && console.log("<SRV> Feed request, params = " + JSON.stringify(req.params));
	app.data.listTweets(req.params)
	.then(function(tweets) {
		res.json(tweets);
	})
	.catch(function(err) {
		app.config.debug && console.log("<SRV> !!! ERROR: ", err);
		res.status(500);
	});
});

// Define tree-testing endpoint
server.get('/test-tree', function(req, res) {
	app.config.debug && console.log("<SRV> * Tree Test, params = " + JSON.stringify(req.params));
	var command = req.params.command || 'TEST';
	app.tree.send(command);
	res.json({
		command: command,
		clients: app.tree.clients.length
	});
});

// Create static route
server.get(/.*/, restify.serveStatic({
	directory: './www',
	default: 'index.html'
}));

// Start Restify server
server.listen(app.config.server.port, function() {
	console.log('<SRV> %s listening at %s', server.name, server.url);
});

// Export server
module.exports = server;
{'fraction_non_alphanumeric': 0.17955010224948875, 'fraction_numerical': 0.0057259713701431495, 'mean_word_length': 4.484304932735426, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5848478', 'n_tokens_mistral': 848, 'n_tokens_neox': 812, 'n_words': 185}