Skip to content

Instantly share code, notes, and snippets.

@pmn

pmn/main.clj Secret

Last active Dec 4, 2017
Embed
What would you like to do?
project.clj
(ns clj.main
(:require [ring.adapter.jetty :as jetty]
[compojure.core :refer [defroutes GET ANY]]
[compojure.route :refer [not-found resources]]
[ring.middleware.reload :refer [wrap-reload]]
[ring.middleware.defaults :refer [wrap-defaults site-defaults]]
[ring.middleware.params :refer [wrap-params]]
[ring.middleware.resource :as resource]
[ring.middleware.cookies :as cookies]
[ring.middleware.gzip :refer [wrap-gzip]]
[clj.route.base :as route-base]
[clj.route.not-found :as route-not-found]
)
(:gen-class))
(defn log-middleware
[handler]
(fn [request]
(println "Request path: " (:uri request))
(handler request)))
(def routes (compojure.core/routes
#'route-base/route
;; not-found is a fallthrough route, it must be last
#'route-not-found/route))
(def handler (-> routes
log-middleware
(resource/wrap-resource "/public")
cookies/wrap-cookies
wrap-params
wrap-gzip))
(def dev-handler (wrap-reload (wrap-defaults #'routes site-defaults)))
(defn start [port]
(jetty/run-jetty handler {:port port
:join? false}))
(defn -main []
(let [port (Integer. (or (System/getenv "PORT") "8081"))]
(start port)))
(defproject agame "0.1.0-SNAPSHOT"
:description "a game"
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.9.229"]
[compojure "1.5.0"]
[cljs-ajax "0.5.4"]
[ring "1.5.1"]
[ring/ring-defaults "0.2.1"]
[amalloy/ring-gzip-middleware "0.1.3"]
[liberator "0.15.1"]
[reagent "0.6.1"]
[secretary "1.2.3"]
[garden "1.3.2"]]
:min-lein-version "2.7.1"
:main clj.main
:ring {:handler clj.main/handler}
:plugins [[lein-ring "0.9.7"]
[lein-cljsbuild "1.1.4" :exclusions [[org.clojure/clojure]]]
[lein-figwheel "0.5.14"]
[lein-garden "0.2.8"]]
:clean-targets ^{:protect false} ["resources/public/js"
"target"
"resources/public/css"]
:figwheel {:css-dirs ["resources/public/css"]
:ring-handler clj.main/dev-handler}
:garden {:builds [{:id "screen"
:source-paths ["src/clj"]
:stylesheet agame.css/screen
:compiler {:output-to "resources/public/css/screen.css"
:pretty-print? true}}]}
:profiles
{:dev
{:dependencies [
[figwheel-sidecar "0.5.10"]
[com.cemerick/piggieback "0.2.1"]
[binaryage/devtools "0.9.0"]
[com.cemerick/piggieback "0.2.1"]]
:plugins [[lein-figwheel "0.5.10"]]
:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}
}}
:cljsbuild
{:builds
[{:id "dev"
:source-paths ["src/cljs"]
:figwheel {:load-warninged-code true
:open-urls ["http://localhost:3449"]}
:compiler {:main "cljs.main"
:optimizations :none
:output-to "resources/public/js/app.js"
:output-dir "resources/public/js/dev"
:asset-path "js/dev"
:source-map-timestamp true
:preloads [devtools.preload]
:external-config
{:devtools/config
{:features-to-install [:formatters :hints]
:fn-symbol "F"
:print-config-overrides true}}}}
{:id "min"
:source-paths ["src/cljs"]
:compiler {:main "cljs.main"
:optimizations :advanced
:output-to "resources/public/js/app.js"
:output-dir "resources/public/js/min"
:elide-asserts true
:closure-defines {goog.DEBUG false}
:pretty-print false}}]})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment