             [taoensso.timbre :refer [info error fatal]]
             [clojure.stacktrace :refer [print-cause-trace]]
             [org.httpkit.server :refer [run-server]]))
-
-(defroutes routes
-  (files "/" {:root (conf/get :out-dir)})
-  (not-found (html5 [:h1 "404"])))
 
 (defn wrap-static-index [handler]
   (fn [{:keys [uri] :as request}]

           (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 \/))

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