<commit_before>#! /usr/bin/env node
var spdy = require('spdy');
var keys = require('spdy-keys');
var ecstatic = require('ecstatic');
var fs = require('fs');
var port = process.argv[2] || 5000;
 
var options = {
  key: keys.key,
  cert: keys.cert,
  ca: keys.ca
};
 
var server = spdy.createServer(options, ecstatic({root: process.cwd() + '/'}));
server.listen(port, function () {
  console.log('Server listening at: https://localhost:%s', port);
});<commit_msg>feat(log): Add logging via morgan<commit_after>var spdy = require('spdy');
var keys = require('spdy-keys');
var ecstatic = require('ecstatic');
var morgan = require('morgan');

module.exports = function (options, cb) {
  options = options || {};

  // determine port & keys
  var port = options.port || 5000;
  var spdyOpts = options.spdy || {
    key: keys.key,
    cert: keys.cert,
    ca: keys.ca
  };

  // create logger "middleware"
  var logger = morgan('combined');

  // create static server "middleware"
  var es = ecstatic({root: process.cwd() + '/'});

  // 
  var middleware = function (req, res) {
    logger(req, res, function (err) {
      if (err) console.error(err);
      es(req, res);
    });
  };

  var server = spdy.createServer(spdyOpts, middleware);
  server.listen(port, cb.bind(server, port) || function () {});
  return server;
};
{'fraction_non_alphanumeric': 0.18057663125948406, 'fraction_numerical': 0.006828528072837633, 'mean_word_length': 3.710714285714286, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '1899879', 'n_tokens_mistral': 457, 'n_tokens_neox': 443, 'n_words': 115}