/*globals process*/

import logger from 'morgan'
import connectAssets from 'connect-assets'
import basicAuth from 'node-basicauth' // TODO: use https://github.com/jshttp/basic-auth and build own middleware
import configRoutes from './routes'
import authData from './basic_auth'

let env = process.env.NODE_ENV || 'development'

export default function configExpressApp (app) {
  if (env === 'production') { app.use(basicAuth(authData)) }
  app.use(logger('combined'))
  app.use(connectAssets())

  return configRoutes(app)
}
