'use strict'

let body = require('body-parser')
let express = require('express')

let ozymandias = module.exports = function () {
  let app = express()

  // No x-powered-by header.
  app.disable('x-powered-by')

  // View Engine
  app.set('view engine', 'ejs')
  app.engine('ejs', require('ejs').renderFile)

  // Are we in production?
  let production = app.get('env') === 'production'

  // Require a secure connection.
  if (process.env.SECURE === '1') app.use(require('./secure'))

  // Static Assets
  app.use(express.static('public', {
    etag: !production,
    lastModified: !production,
    maxAge: production ? '1d' : 0
  }))

  // S3 Assets
  app.use('/assets', require('./assets'))

  // Middleware
  app.use(require('compression')())
  app.use(require('./helpers'))
  app.use(require('./layout'))
  app.use(require('./mail'))
  app.use(body.json())
  app.use(body.urlencoded({extended: false}))

  return app
}

for (let p in express) ozymandias[p] = express[p]

@@ -476,24 +476,97 @@
 /secure'))%0A%0A
+  // Compress responses by default.%0A  app.use(require('compression')())%0A%0A
   // Static 
@@ -771,54 +771,117 @@
  // 
-Middleware%0A  app.use(require('compression')())
+Parse the request body.%0A  app.use(body.json())%0A  app.use(body.urlencoded(%7Bextended: false%7D))%0A%0A  // Middleware
 %0A  a
@@ -972,77 +972,8 @@
 l'))
-%0A  app.use(body.json())%0A  app.use(body.urlencoded(%7Bextended: false%7D))
 %0A%0A  

Compress static assets.