-fs     = require "fs"
-http   = require "https"
-mime   = require "mime"
-crypto = require "crypto"
-parser = require "url"
+fs     = require 'fs'
+http   = require 'https'
+mime   = require 'mime'
+crypto = require 'crypto'
+parser = require 'url'
 
 {
   embedly : {

  if fs.existsSync filename
    return serveFile filename, res

  http.get fullUrl, (response)->
    response.pipe(fs.createWriteStream(filename)).on 'close', ->
      serveFile filename, res

  }
} = KONFIG

imagePath = 'embedly_cache'

fs.mkdir imagePath, null, ->

module.exports = (req, res) ->
  { endpoint, grow, width, height, url } = req.query

  fullUrl = "https://i.embed.ly/1/display/#{endpoint}?" +
             "width=#{width}&" +
