<commit_before>const Koa = require('koa')
const _ = require('lodash')
const Router = require('koa-router')
const koaLogger = require('koa-logger')
const cors = require('kcors')
const throttle = require('koa-ratelimit')
const serve = require('koa-static')
const compress = require('koa-compress')
const convert = require('koa-convert')
const morgan = require('koa-morgan')
const helmet = require('koa-helmet')
const logger = require('./logger')
const fs = require('fs')
const koaqs = require('koa-qs')
const bodyParser = require('koa-body')

module.exports = class Koapi {
  constructor () {
    this.koa = koaqs(new Koa())
    this.config = {}
    this.server = null
    this.listeners = { teardown: e => logger.info('server stopped') }
    this.koa.on('error', e => logger.error(e))
  }

  bodyparser (options) {
    options = Object.assign({ multipart: true }, options)
    this.koa.use(bodyParser(options))
  }

  debug (on) {
    if (on) this.koa.use(koaLogger())
    return this
  }

  cors (options) {
    if (options) this.koa.use(cors(options))
    return this
  }

  throttle (options) {
    if (options) this.koa.use(convert(throttle(options)))
    return this
  }

  serve (config) {
    if (config) this.koa.use(serve(config.root, config.options))
    return this
  }

  accesslog (config) {<commit_msg>fixed dep<commit_after>const Koa = require('koa')
const _ = require('lodash')
const Router = require('koa-router')
const koaLogger = require('koa-logger')
const cors = require('kcors')
const throttle = require('koa-ratelimit')
const serve = require('koa-static')
const compress = require('koa-compress')
const convert = require('koa-convert')
const morgan = require('koa-morgan')
const helmet = require('koa-helmet')
const logger = require('./logger')
const fs = require('fs')
const koaqs = require('koa-qs')
const bodyParser = require('koa-body')
const os = require('os')

module.exports = class Koapi {
  constructor () {
    this.koa = koaqs(new Koa())
    this.config = {}
    this.server = null
    this.listeners = { teardown: e => logger.info('server stopped') }
    this.koa.on('error', e => logger.error(e))
  }

  bodyparser (options) {
    options = Object.assign({
      multipart: true,
      formidable: { uploadDir: os.tmpdir() }
    }, options)
    this.koa.use(bodyParser(options))
  }

  debug (on) {
    if (on) this.koa.use(koaLogger())
    return this
  }

  cors (options) {
    if (options) this.koa.use(cors(options))
    return this
  }

  throttle (options) {
    if (options) this.koa.use(convert(throttle(options)))
    return this
  }

  serve (config) {
    if (config) this.koa.use(serve(config.root, config.options))
    return this
  }

  accesslog (config) {
{'fraction_non_alphanumeric': 0.15773919468045808, 'fraction_numerical': 0.0, 'mean_word_length': 3.767605633802817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7095782', 'n_tokens_mistral': 943, 'n_tokens_neox': 923, 'n_words': 209}