<commit_before>import express from 'express';
import mustacheExpress from 'mustache-express';
import Io from 'socket.io';
import http from 'http';
import shortid from 'shortid';
import _ from 'underscore';
import Room from './room';
import favicon from 'serve-favicon';
import compression from 'compression';
import fs from 'fs';

const app = express();
const server = http.createServer(app);
const io = Io(server);

let rooms = [];

app.use(compression());
app.use(favicon(__dirname + '/public/favicon.ico'));
app.engine('mustache', mustacheExpress());
app.set('view engine', 'mustache');
app.set('views', __dirname + '/views');
app.use(express.static(__dirname + '/public'));

function generateNewRoom(req, res, id) {
  const room = new Room(io, id);
  rooms.push(room);
  console.log('generating new room');

  room.on('empty', function() {
    rooms = _.without(rooms, _.findWhere(rooms, {_id: room._id}));
  });

  return res.redirect(`/${id}`);
}

app.get('/', (req, res) => {
  const id = shortid.generate();
  generateNewRoom(req, res, id);
});

app.get('/:roomId', (req, res) => {
  const roomId = req.params.roomId || false;

  let roomExists = _.findWhere(rooms, {_id: roomId}) || false;

  if (roomExists) {
    return res.render('index', {username: shortid.generate()});
  }

  return res.redirect('/');
});

server.listen(3000, () => {
  console.log('darkwire is online.');
});<commit_msg>Configurable port<commit_after>import _ from 'underscore';
import express from 'express';
import mustacheExpress from 'mustache-express';
import Io from 'socket.io';
import http from 'http';
import shortid from 'shortid';
import favicon from 'serve-favicon';
import compression from 'compression';
import fs from 'fs';

import Room from './room';

const $PORT = 3000;

const app = express();
const server = http.createServer(app);
const io = Io(server);

let rooms = [];

app.use(compression());
app.use(favicon(__dirname + '/public/favicon.ico'));
app.engine('mustache', mustacheExpress());
app.set('view engine', 'mustache');
app.set('views', __dirname + '/views');
app.use(express.static(__dirname + '/public'));

function generateNewRoom(req, res, id) {
  const room = new Room(io, id);
  rooms.push(room);
  console.log('generating new room');

  room.on('empty', function() {
    rooms = _.without(rooms, _.findWhere(rooms, {_id: room._id}));
  });

  return res.redirect(`/${id}`);
}

app.get('/', (req, res) => {
  const id = shortid.generate();
  generateNewRoom(req, res, id);
});

app.get('/:roomId', (req, res) => {
  const roomId = req.params.roomId || false;

  let roomExists = _.findWhere(rooms, {_id: roomId}) || false;

  if (roomExists) {
    return res.render('index', {username: shortid.generate()});
  }

  return res.redirect('/');
});

server.listen($PORT, () => {
  console.log(`darkwire is online on port ${$PORT}.`);
});
{'fraction_non_alphanumeric': 0.19157894736842104, 'fraction_numerical': 0.002807017543859649, 'mean_word_length': 4.830265848670757, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '7263563', 'n_tokens_mistral': 949, 'n_tokens_neox': 929, 'n_words': 245}