mirror of
https://gitlab.com/wheres-the-tp/server.git
synced 2026-01-25 04:34:55 -06:00
move app config to separate module with main
This commit is contained in:
parent
842e78daef
commit
16bcc4de5d
4 changed files with 49 additions and 39 deletions
2
Procfile
2
Procfile
|
|
@ -1 +1 @@
|
|||
web: lein ring server-headless
|
||||
web: java $JVM_OPTS -cp target/aretherecookies.jar aretherecookies.app
|
||||
|
|
@ -2,9 +2,8 @@
|
|||
:description "where cookies can be found"
|
||||
:url "http://www.aretherecookies.com"
|
||||
:min-lein-version "2.0.0"
|
||||
:main aretherecookies.handler
|
||||
:dependencies [
|
||||
[org.clojure/clojure "1.8.0"]
|
||||
:main aretherecookies.app
|
||||
:dependencies [[org.clojure/clojure "1.8.0"]
|
||||
[environ "1.1.0"]
|
||||
[compojure "1.5.1"]
|
||||
[ring/ring-defaults "0.2.1"]
|
||||
|
|
@ -14,9 +13,9 @@
|
|||
[ring-middleware-format "0.7.2"]
|
||||
[org.clojure/data.json "0.2.6"]
|
||||
[ring/ring-json "0.4.0"]
|
||||
]
|
||||
[ring/ring-jetty-adapter "1.4.0"]]
|
||||
:plugins [[lein-ring "0.9.7"] [lein-environ "1.1.0"]]
|
||||
:ring {:handler aretherecookies.handler/app}
|
||||
:ring {:handler aretherecookies.app/app}
|
||||
:profiles
|
||||
{:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
|
||||
[ring/ring-mock "0.3.0"]]}
|
||||
|
|
|
|||
15
src/aretherecookies/app.clj
Normal file
15
src/aretherecookies/app.clj
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
(ns aretherecookies.app
|
||||
(:gen-class)
|
||||
(:require [aretherecookies.handler :refer [app-routes]]
|
||||
[environ.core :refer [env]]
|
||||
[compojure.handler :refer [site]]
|
||||
[ring.adapter.jetty :as jetty]
|
||||
[ring.middleware.defaults :refer [wrap-defaults api-defaults]]))
|
||||
|
||||
(def app-config (assoc-in api-defaults [:security :anti-forgery] false))
|
||||
|
||||
(def app (wrap-defaults app-routes app-config))
|
||||
|
||||
(defn -main [& [port]]
|
||||
(let [port (Integer. (or port (env :port) 3000))]
|
||||
(jetty/run-jetty (site #'app) {:port port :join? false})))
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
(:require [aretherecookies.db :refer [query-food-items build-fooditems-query]]
|
||||
[compojure.core :refer :all]
|
||||
[compojure.route :as route]
|
||||
[ring.middleware.defaults :refer [wrap-defaults site-defaults]]
|
||||
[clojure.data.json :as json]
|
||||
[clojure.string :as str]
|
||||
[ring.middleware.anti-forgery :refer :all]
|
||||
|
|
@ -52,6 +51,3 @@
|
|||
(POST "/test" req "ok")
|
||||
(POST "/fooditems" req (wrap-json-body food-items-handler))
|
||||
(GET "/echo" [location orderby filter] (str location orderby filter)))
|
||||
|
||||
(def app
|
||||
(wrap-defaults app-routes (assoc-in site-defaults [:security :anti-forgery] false)))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue