<commit_before>import Koa from 'koa'
import Router from 'koa-router'
import convert from 'koa-convert'
import bodyParser from 'koa-bodyparser'
import webpack from 'webpack'
import webpackConfig from '../build/webpack.config'
import historyApiFallback from 'koa-connect-history-api-fallback'
import serve from 'koa-static'
import proxy from 'koa-proxy'
import _debug from 'debug'
import json from 'koa-json'
import dotenv from 'dotenv'
import config from '../config'
import webpackDevMiddleware from './middleware/webpack-dev'
import webpackHMRMiddleware from './middleware/webpack-hmr'
import loadRoutes from './api'
import logger from './lib/logger'

const debug = _debug('app:server')
const paths = config.utils_paths
const app = new Koa()
const router = new Router({ prefix: '/api' })

// basic error logging
// app.on('error', (err, ctx) => {
//   logger.error(`Error: ${err}`)
//   logger.error(`ctx was ${ctx}`)
// })

// Enable koa-proxy if it has been enabled in the config.
if (config.proxy && config.proxy.enabled) {
  app.use(convert(proxy(config.proxy.options)))
}

app.use(json())
app.use(bodyParser())

// Load ENV vars
dotenv.config()

// use router for api
loadRoutes(router)
app.use(router.routes())
app.use(router.allowedMethods())

// This rewrites all routes requests to the root /index.html file
// (ignoring file requests). If you want to implement isomorphic
// rendering, you'll want to remove this middleware.
app.use(convert(historyApiFallback({
  verbose: false
})))

// ------------------------------------
// Apply Webpack HMR Middleware
// ------------------------------------
if (config.env === 'development') {<commit_msg>remove more dead code<commit_after>import Koa from 'koa'
import Router from 'koa-router'
import convert from 'koa-convert'
import bodyParser from 'koa-bodyparser'
import webpack from 'webpack'
import webpackConfig from '../build/webpack.config'
import historyApiFallback from 'koa-connect-history-api-fallback'
import serve from 'koa-static'
import proxy from 'koa-proxy'
import _debug from 'debug'
import json from 'koa-json'
import dotenv from 'dotenv'
import config from '../config'
import webpackDevMiddleware from './middleware/webpack-dev'
import webpackHMRMiddleware from './middleware/webpack-hmr'
import loadRoutes from './api'

const debug = _debug('app:server')
const paths = config.utils_paths
const app = new Koa()
const router = new Router({ prefix: '/api' })

// Enable koa-proxy if it has been enabled in the config.
if (config.proxy && config.proxy.enabled) {
  app.use(convert(proxy(config.proxy.options)))
}

app.use(json())
app.use(bodyParser())

// Load ENV vars
dotenv.config()

// use router for api
loadRoutes(router)
app.use(router.routes())
app.use(router.allowedMethods())

// This rewrites all routes requests to the root /index.html file
// (ignoring file requests). If you want to implement isomorphic
// rendering, you'll want to remove this middleware.
app.use(convert(historyApiFallback({
  verbose: false
})))

// ------------------------------------
// Apply Webpack HMR Middleware
// ------------------------------------
if (config.env === 'development') {
{'fraction_non_alphanumeric': 0.17132867132867133, 'fraction_numerical': 0.0, 'mean_word_length': 3.6279411764705882, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '6366675', 'n_tokens_mistral': 935, 'n_tokens_neox': 930, 'n_words': 304}