 {Databank, DatabankObject} = require 'databank'
 Logger = require 'bunyan'
 uuid = require 'node-uuid'
+request = require 'request'
 
 HTTPError = require './httperror'
 

    exp.use requestLogger
    exp.use bodyParser.json()

    # Error handler

    exp.use (err, req, res, next) ->
      if err.name == "NoSuchThingError"
        res.statusCode = 404
      else
        res.statusCode = err.statusCode or 500
      if req.log
        req.log.error {err: err}, "Error"
      res.setHeader "Content-Type", "application/json"
      res.json {message: err.message}

    @setupRoutes exp

    exp.config = @config

    exp


      cert: environment['CERT']
      logLevel: environment['LOG_LEVEL'] || 'info'
      logFile: environment['LOG_FILE'] || null
      stripeHook: environment['STRIPE_HOOK']
      driver: environment['DRIVER']
      params: if environment['PARAMS'] then JSON.parse(environment['PARAMS']) else {}
      appKeys: {}
