<commit_before>var express = require('express');
var fs = require('fs');

var port = 9009;
var app = express();

var countries = require('./data/countries.json');

app.get('/countries', function(req, res) {
  res.type('application/json');

  var query = req.query.q;

  var filteredCountries = query ? countries.filter(function(country) {
    return country.name.common.toLowerCase().indexOf(query.toLowerCase()) !== -1;
  }) : countries;

  if (!filteredCountries) {
    res.statusCode = 404;
    return res.send('No countries found with query ' + query + '!');
  } else {
    res.statusCode = 200;
    return res.send(JSON.stringify(filteredCountries));
  }
});

app.listen(port);
console.log('Application started on port ' + port);<commit_msg>Refactoring for better readability<commit_after>var express = require('express');
var fs = require('fs');

var port = 9009;
var app = express();

var countries = require('./data/countries.json');

app.get('/countries', function(req, res) {
  res.type('application/json');

  var query = req.query.q;

  var filteredCountries;

  if (query) {
    filteredCountries = countries.filter(function(country) {
      return country.name.common.toLowerCase().indexOf(query.toLowerCase()) !== -1;
    });
  } else {
    filteredCountries = countries;
  }

  if (!filteredCountries) {
    res.statusCode = 404;
    return res.send('No countries found with query ' + query + '!');
  } else {
    res.statusCode = 200;
    return res.send(JSON.stringify(filteredCountries));
  }
});

app.listen(port);
console.log('Application started on port ' + port);
{'fraction_non_alphanumeric': 0.16078184110970997, 'fraction_numerical': 0.013871374527112233, 'mean_word_length': 4.054140127388535, 'pattern_counts': {'":': 0, '<': 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': '4238332', 'n_tokens_mistral': 510, 'n_tokens_neox': 488, 'n_words': 110}