<commit_before>import http from 'http'
import express from 'express'
import expressValidator from 'express-validator'
import bodyParser from 'body-parser'
import cors from 'cors'
import jsend from 'jsend'
import morgan from 'morgan'
import validators from './util/validators'
import api from './routes'
import setStatusMiddleware from './middlewares/format-errors'

const app = express()
app.server = http.createServer(app)

// 3rd party middleware
app.use(cors({
  exposedHeaders: ['Link'],
}))

app.use(bodyParser.json({
  limit: '100kb',
}))

app.use(bodyParser.urlencoded({
  extended: true,
}))

app.use(expressValidator({
  customValidators: validators,
}))

app.use(jsend.middleware)

app.use(setStatusMiddleware)

// api router
app.use(api)


// no need to start a server when testing
if (process.env.NODE_ENV !== 'test') {
  app.use(morgan('combined'))<commit_msg>Log with morgan before routes are loaded<commit_after>import http from 'http'
import express from 'express'
import expressValidator from 'express-validator'
import bodyParser from 'body-parser'
import cors from 'cors'
import jsend from 'jsend'
import morgan from 'morgan'
import validators from './util/validators'
import api from './routes'
import setStatusMiddleware from './middlewares/format-errors'

const app = express()
app.server = http.createServer(app)

// 3rd party middleware
app.use(cors({
  exposedHeaders: ['Link'],
}))

app.use(bodyParser.json({
  limit: '100kb',
}))

app.use(bodyParser.urlencoded({
  extended: true,
}))

app.use(expressValidator({
  customValidators: validators,
}))

app.use(jsend.middleware)

app.use(setStatusMiddleware)

if (process.env.NODE_ENV !== 'test') {
  app.use(morgan('combined'))
}

// api router
app.use(api)


// don't start a server when testing
if (process.env.NODE_ENV !== 'test') {
{'fraction_non_alphanumeric': 0.13812154696132597, 'fraction_numerical': 0.004419889502762431, 'mean_word_length': 5.2020547945205475, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6457908', 'n_tokens_mistral': 592, 'n_tokens_neox': 590, 'n_words': 160}