   res.locals = context
   res.render template, partials: partials
 
+# Start server
+
 port = process.env.PORT || 5000
 app.listen port, ->
   console.log "Server up on port #{port}"

presenter = require './lib/presenter'
helpers = require "./lib/helpers"

throw "Nodefly API Key not configured! ($NODEFLY_API_KEY)" unless process.env.NODEFLY_API_KEY
require('nodefly').profile(
  process.env.NODEFLY_API_KEY,
  'Busted',
  {}
)

app = express()

app.set 'view engine', 'mustache'
app.set 'layout', 'layout'
# app.set 'partials', head: 'head'
app.enable 'view cache' if app.settings.env is "production"
app.engine 'mustache', require 'hogan-express'

app.use express.bodyParser()

throw "CTA API Key not configured! ($CTA_API_KEY)" unless process.env.CTA_API_KEY
app.set 'apiKey', process.env.CTA_API_KEY

app.get "/", (req, res) ->
  renderHTML

  else
    renderSMS res, 400, "Error: Your message must include a bus number"

# Helpers

renderSMS = (res, status, message) ->
  console.log "[Resposne (SMS)]: ", {status, message}
  truncatedMessage = message.substring 0, 160
