{"size": 1198, "ext": "js", "max_stars_repo_path": "server/express.js", "max_stars_repo_name": "npm-wharf/etcdeck", "max_stars_repo_stars_event_min_datetime": "2017-07-20T18:33:43.000Z", "max_stars_repo_stars_event_max_datetime": "2017-10-27T20:07:45.000Z", "max_issues_repo_path": "server/express.js", "max_issues_repo_name": "arobson/etcdeck", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server/express.js", "max_forks_repo_name": "arobson/etcdeck", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 6, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.2195121951, "max_line_length": 73, "alphanum_fraction": 0.6819699499}
const bodyParser = require('body-parser')
const cookieParser = require('cookie-parser')
const compression = require('compression')
const express = require('express')
const info = require('../package.json')

function configure (auth, state) {
  const app = state.express
  app.use(infoHeaders)

  app.use(cookieParser())
  app.use('/', bodyParser.urlencoded({ extended: false }))
  app.use('/', bodyParser.json())
  app.use('/', bodyParser.json({ type: 'application/vnd.api+json' }))
  app.use('/', bodyParser.text({ type: 'text/plain' }))
  app.use(compression())
  return Promise.resolve()
}

function postRouting (state) {
  // this exists to get around browser behavior related to browserHistory
  // need to add a check to this so it only applies in situations where
  // a user agent is making the request
  state.express.use('/', express.static('./build'))
  // state.express.get('*', function (req, res) {
  //   res.sendFile(path.resolve('./public/index.html'))
  // })
}

function infoHeaders (req, res, next) {
  res.set('X-App-Version', info.version)
  next()
}

module.exports = function (auth) {
  return {
    configure: configure.bind(null, auth),
    postRouting: postRouting
  }
}
