<commit_before>// Main Express Router -- ToonHQ Clone
// Created by @gaarb

// Modules

var express = require('express');
var app = express();
var bp = require('body-parser');
var morgan = require('morgan');
var colours = require('colors');

var Invasion = require('./modules/invasions');
var Status = require('./modules/status');

// Configuration

var feVal = "::1"; // IP of the front-end so it doesn't get logged in console.

var port = process.env.PORT || 8080; // Designating the port.
var router = express.Router(); // Allowing us to create our routes.

app.use('/api/v1/', router); // Registering the routes.

app.use(morgan('dev'));
app.use(bp.urlencoded({ extended: true }));
app.use(bp.json());

// Middleware -- This is used so when we know if an infected connection is incoming.

router.use(function(req, res, next){
  if (req.connection.remoteAddress == feVal) {
    next();
  } else  {
    console.log('[Middleware] There is an incoming connection coming from: ' + req.connection.remoteAddress + '.'.red);
    next();
  }
});

// Routers

router.get('/', function(req, res) {
  res.json(
    { message: "Welcome to ToonHQ Clone API!" }
  );
});

router.get('/invasions', Invasion.sendInvasionList);

router.get('/status', Status.returnServerStatus);

// Finalise

app.listen(port);
console.log('[Server] Web-server has successfully started!'.yellow);
<commit_msg>Fix an issue with cross-domain.<commit_after>// Main Express Router -- ToonHQ Clone
// Created by @gaarb

// Modules

var express = require('express');
var app = express();
var bp = require('body-parser');
var morgan = require('morgan');
var colours = require('colors');

var Invasion = require('./modules/invasions');
var Status = require('./modules/status');

// Configuration

var feVal = "::1"; // IP of the front-end so it doesn't get logged in console.

var port = process.env.PORT || 8080; // Designating the port.
var router = express.Router(); // Allowing us to create our routes.

app.use('/api/v1/', router); // Registering the routes.

app.use(morgan('dev'));
app.use(bp.urlencoded({ extended: true }));
app.use(bp.json());

// Middleware -- This is used so when we know if an infected connection is incoming.

router.use(function(req, res, next){
  if (req.connection.remoteAddress == feVal) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "X-Requested-With");
    next();
  } else  {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "X-Requested-With");
    console.log('[Middleware] There is an incoming connection coming from: ' + req.connection.remoteAddress + '.'.red);
    next();
  }
});

// Routers

router.get('/', function(req, res) {
  res.json(
    { message: "Welcome to ToonHQ Clone API!" }
  );
});

router.get('/invasions', Invasion.sendInvasionList);

router.get('/status', Status.returnServerStatus);

// Finalise

app.listen(port);
console.log('[Server] Web-server has successfully started!'.yellow);

{'fraction_non_alphanumeric': 0.1745189117451891, 'fraction_numerical': 0.003981420039814201, 'mean_word_length': 3.934533551554828, 'pattern_counts': {'":': 2, '<': 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': '3562233', 'n_tokens_mistral': 957, 'n_tokens_neox': 942, 'n_words': 264}