<commit_before>{createServer} = require 'connect'
{createPool}   = require './pool'
{dirname}      = require 'path'

exports.createServer = (config, options) ->
  options ?= {}
  options.size ?= 3
  options.idle ?= 15 * 60 * 1000
  options.cwd  ?= dirname(config)

  pool = createPool config, options

  server = createServer (req, res, next) ->
    pool.proxyRequest req, res, (err) ->
      if err
        next err

  server.on 'close', ->
    pool.quit()<commit_msg>Add inline docs to server<commit_after>{createServer} = require 'connect'
{createPool}   = require './pool'
{dirname}      = require 'path'

# Creates a [Connect](http://senchalabs.github.com/connect/)
# compatible server.
#
# You can use it similar to **http.createServer**
#
#     var server = nack.createServer("/path/to/app/config.ru");
#     server.listen(3000);
#
# Or with **Connect** middleware
#
#     var connect = require('connect');
#     var server = connect.createServer(
#       connect.logger(),
#       nack.createServer("/path/to/app/config.ru"),
#       connect.errorHandler({ dumpExceptions: true })
#     );
#
exports.createServer = (config, options) ->
  options ?= {}
  options.size ?= 3
  options.idle ?= 15 * 60 * 1000
  options.cwd  ?= dirname(config)

  pool = createPool config, options

  server = createServer (req, res, next) ->
    pool.proxyRequest req, res, (err) ->
      if err
        next err

  server.on 'close', ->
    pool.quit()
{'fraction_non_alphanumeric': 0.15555555555555556, 'fraction_numerical': 0.015277777777777777, 'mean_word_length': 3.047752808988764, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '1167757', 'n_tokens_mistral': 489, 'n_tokens_neox': 459, 'n_words': 116}