|
|
|
@@ -1,4 +1,4 @@
|
|
|
|
|
(ns vibe.core
|
|
|
|
|
(ns tbd.core
|
|
|
|
|
(:require [ring.adapter.jetty :as jetty]
|
|
|
|
|
[ring.middleware.defaults :refer [wrap-defaults api-defaults]]
|
|
|
|
|
[ring.middleware.head :refer [wrap-head]]
|
|
|
|
@@ -7,22 +7,22 @@
|
|
|
|
|
[reitit.swagger-ui :as swagger-ui]
|
|
|
|
|
[reitit.ring.middleware.muuntaja :as muuntaja-middleware]
|
|
|
|
|
[muuntaja.core :as m]
|
|
|
|
|
[vibe.health.routes :as health]
|
|
|
|
|
[vibe.math.routes :as math]))
|
|
|
|
|
[tbd.health.routes :as health]
|
|
|
|
|
[tbd.math.routes :as math]))
|
|
|
|
|
|
|
|
|
|
;; Each logical group (health, users, orders, ...) owns a `vibe.<group>.routes`
|
|
|
|
|
;; Each logical group (health, users, orders, ...) owns a `tbd.<group>.routes`
|
|
|
|
|
;; namespace that returns its own route subtree; they're concatenated here.
|
|
|
|
|
(def router
|
|
|
|
|
(ring/router
|
|
|
|
|
[["/swagger.json"
|
|
|
|
|
{:get {:no-doc true
|
|
|
|
|
:swagger {:info {:title "vibe API" :version "1.0.0"}}
|
|
|
|
|
:swagger {:info {:title "tbd API" :version "1.0.0"}}
|
|
|
|
|
:handler (swagger/create-swagger-handler)}}]
|
|
|
|
|
["/" {:get {:no-doc true
|
|
|
|
|
:handler (fn [_req]
|
|
|
|
|
{:status 200
|
|
|
|
|
:headers {"Content-Type" "text/plain; charset=utf-8"}
|
|
|
|
|
:body "vibe API — see /api-docs for documentation, /swagger.json for the spec"})}}]
|
|
|
|
|
:body "tbd API — see /api-docs for documentation, /swagger.json for the spec"})}}]
|
|
|
|
|
(health/routes)
|
|
|
|
|
(math/routes)]
|
|
|
|
|
{:data {:muuntaja m/instance
|
|
|
|
@@ -44,15 +44,15 @@
|
|
|
|
|
(defn start-server [& [_ opts]]
|
|
|
|
|
(let [port (Integer/parseInt (str (or (System/getenv "PORT")
|
|
|
|
|
(get opts :port 3000))))]
|
|
|
|
|
(println (format "[vibe] starting server on port %d..." port))
|
|
|
|
|
(println (format "[tbd] starting server on port %d..." port))
|
|
|
|
|
(try
|
|
|
|
|
(let [server (jetty/run-jetty (wrap-defaults app api-defaults)
|
|
|
|
|
{:port port
|
|
|
|
|
:join? false})]
|
|
|
|
|
(println (format "vibe server running on http://localhost:%d" port))
|
|
|
|
|
(println (format "tbd server running on http://localhost:%d" port))
|
|
|
|
|
(add-shutdown-hook server))
|
|
|
|
|
(catch Throwable t
|
|
|
|
|
(println "[vibe] FAILED to start server:" (.getMessage t))
|
|
|
|
|
(println "[tbd] FAILED to start server:" (.getMessage t))
|
|
|
|
|
(.printStackTrace t)
|
|
|
|
|
(throw t)))))
|
|
|
|
|
|