Skip to content

Instantly share code, notes, and snippets.

Last active September 18, 2016 21:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dadair-ca/eb0d4bcb5b88e6d1741986a5aad4c93c to your computer and use it in GitHub Desktop.
--- jwt ---
Starting HTTP server on port nil
{:hide-errors duct.middleware.errors/wrap-hide-errors,
:not-found duct.middleware.not-found/wrap-not-found,
:ring-json-response ring.middleware.json/wrap-json-response,
:ring-json-body ring.middleware.json/wrap-json-body},
[:ring-json-body :ring-json-response :not-found :hide-errors],
{:not-found "Resource Not Found",
:hide-errors "Internal Server Error",
:ring-json-body {:keywords? true, :bigdecimals? true}}}},
:http {:app nil},
{:email "",
:password "secret",
:role "user"}}
{:email "..",
:password "secret",
:role "admin"}}]>},
:jwt {:secret nil, :opts nil},
:root {:build-routes #'api.endpoint.root/root-endpoint},
:auth {:build-routes #'api.endpoint.auth/auth-endpoint}}
(ns api.component.jwt
(:require [com.stuartsierra.component :as component]
(defrecord JWT [secret opts]
(start [this] this)
(stop [this] this))
(defn jwt [config]
(println "--- jwt ---")
(clojure.pprint/pprint config)
(map->JWT config))
(ns api.main
(:require [com.stuartsierra.component :as component]
[duct.util.runtime :refer [add-shutdown-hook]]
[duct.util.system :refer [load-system]]
[environ.core :refer [env]]
[ :as io]
(defn -main [& args]
(let [system (load-system [(io/resource "api/system.edn")])]
(println "Starting HTTP server on port" (-> system :http :port))
(clojure.pprint/pprint system)
#_(add-shutdown-hook ::stop-system #(component/stop system))
#_(component/start system)))
{:app duct.component.handler/handler-component
:http ring.component.jetty/jetty-server
:db api.boundary.UsersDatabase/fakedb
:jwt api.component.jwt/jwt}
{:root api.endpoint.root/root-endpoint
:auth api.endpoint.auth/auth-endpoint}
{:http [:app]
:app [:root :auth]
:auth [:db :jwt]}
{:hide-errors duct.middleware.errors/wrap-hide-errors
:not-found duct.middleware.not-found/wrap-not-found
:ring-json-response ring.middleware.json/wrap-json-response
:ring-json-body ring.middleware.json/wrap-json-body}
[:ring-json-body :ring-json-response
:not-found :hide-errors]
{:not-found "Resource Not Found"
:hide-errors "Internal Server Error"
:ring-json-body {:keywords? true :bigdecimals? true}}}}}
{:port 3000}
{:secret "jwt-secret-prod"
:opts {:alg :hs512}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment