 (ns incise.server
   (:require (compojure [route :refer [files not-found]]
-                       [core :refer [defroutes]])
+                       [core :refer [routes]])
             (hiccup [page :refer [html5]])
             (incise [config :as conf]
                     [load :refer [load-parsers-and-layouts]])

           (fatal cause-trace)))
        (when bubble (throw e))))))

(def app (-> routes
             (wrap-static-index)
             (wrap-reload :dirs ["src" "spec"])
             (wrap-incise)
             (wrap-log-exceptions)
             (wrap-stacktrace-web)
             (asset-pipeline)))

(defn getenv
  "A nice wrapper around System/getenv that allows a second argument to be
  passed in as the default."
  [variable & [default]]
  (or (System/getenv variable) default))

(defn serve
  "Start the development server"
  []
  (let [port (Integer. (conf/get :port (getenv "PORT" 5000)))]
    (info "Serving at"
          (str "http://" (.getCanonicalHostName
                           (java.net.InetAddress/getLocalHost)) \: port \/))

            [taoensso.timbre :refer [info error fatal]]
            [clojure.stacktrace :refer [print-cause-trace]]
            [org.httpkit.server :refer [run-server]]))

(defn wrap-static-index [handler]
  (fn [{:keys [uri] :as request}]
