const bodyParser = require('body-parser')
const express = require('express')
const jwt = require('express-jwt')
const path = require('path')
const html = require('@conveyal/woonerf/html')

const routes = require('./routes')

const SECRET = process.env.AUTH0_SECRET

const app = express()

// middleware
if (SECRET) {
  app.use(jwt({secret: SECRET}))
}
app.use(bodyParser.json())

// static assets
app.use('/assets', express.static(path.resolve(__dirname, '../assets')))

// api
routes(app)

// webapp
app.get('*', (req, res) =>
  res.status(200).type('html').send(html({title: 'Commute'})))

module.exports = app

@@ -484,16 +484,629 @@
 s(app)%0A%0A
+let htmlString%0Aconst title = 'Commute'%0Aif (process.env.MONGODB_URI) %7B%0A  // In heroku environment, get js and css from s3%0A  const host = process.env.STATIC_HOST%0A  htmlString = %60%3C!DOCTYPE html%3E%0A  %3Chtml%3E%0A    %3Chead%3E%0A      %3Cmeta charset=%22utf-8%22%3E%0A      %3Cmeta name=%22viewport%22 content=%22width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0%22%3E%0A      %3Clink href=%22$%7Bhost%7Dassets/index.css%22 rel=%22stylesheet%22%3E%0A%0A      %3Ctitle%3E$%7Btitle%7D%3C/title%3E%0A    %3C/head%3E%0A    %3Cbody%3E%0A      %3Cdiv id=%22root%22%3E%3C/div%3E%0A      %3Cscript src=%22$%7Bhost%7Dassets/index.js%22%3E%3C/script%3E%0A    %3C/body%3E%0A  %3C/html%3E%0A  %60%0A%7D else %7B%0A  htmlString = html(%7Btitle%7D)%0A%7D%0A%0A
 // webap
@@ -1133,18 +1133,16 @@
  res) =%3E
-%0A 
  res.sta
@@ -1176,28 +1176,14 @@
 html
-(%7Btitle: 'Commute'%7D)
+String
 ))%0A%0A

use s3 to serve static files