             [compojure.route :refer [resources]]
             [compojure.handler :refer [api]]
             [compojure.core :refer [GET POST routes defroutes context]]
-            [ring.middleware.defaults :refer [wrap-defaults site-defaults]]
+            [ring.middleware.defaults :refer [wrap-defaults secure-site-defaults site-defaults]]
             [ring.middleware.edn :refer [wrap-edn-params]]
+            [taoensso.carmine.ring :as carmine]
             [chat.server.sync :refer [sync-routes]]
+            [environ.core :refer [env]]
             [chat.server.db :as db]))
 
 (defn edn-response [clj-body]

(defroutes resource-routes
  (resources "/"))

(def app
  (->
    (wrap-defaults

        resource-routes
        site-routes
        sync-routes)
      (-> (if (= (env :environment) "prod")
            secure-site-defaults
            site-defaults)
          (assoc-in [:session :store] (carmine/carmine-store *redis-conf*
                                                             {:expiration-secs (* 60 60 24 7)
                                                              :key-prefix "lpchat"}))
          (assoc-in [:security :anti-forgery]
            {:read-token (fn [req] (-> req :params :csrf-token))})))
      wrap-edn-params))
