Create a config map
For now, the config contains: - database "credentials" (safe to commit, it's just the name of the sqlite file) - port on which the HTTP server will listen
This commit is contained in:
@@ -10,6 +10,11 @@
|
|||||||
[next.jdbc.result-set :as rs])
|
[next.jdbc.result-set :as rs])
|
||||||
(:gen-class))
|
(:gen-class))
|
||||||
|
|
||||||
|
;; Configuration --------------------------------------------------
|
||||||
|
(def config
|
||||||
|
{:db {:dbtype "sqlite" :dbname "yohoho.db"}
|
||||||
|
:server {:port 3000}})
|
||||||
|
|
||||||
|
|
||||||
;; Data schema ----------------------------------------------------
|
;; Data schema ----------------------------------------------------
|
||||||
;; Malli schemas for validation
|
;; Malli schemas for validation
|
||||||
@@ -27,7 +32,7 @@
|
|||||||
|
|
||||||
|
|
||||||
;; Database stuff -------------------------------------------------
|
;; Database stuff -------------------------------------------------
|
||||||
(def db {:dbtype "sqlite" :dbname "yohoho.db"})
|
(def db (:db config))
|
||||||
|
|
||||||
(defn init-db!
|
(defn init-db!
|
||||||
"Create database structure if needed"
|
"Create database structure if needed"
|
||||||
@@ -135,8 +140,8 @@
|
|||||||
"HolidayPirates take-home assignement.
|
"HolidayPirates take-home assignement.
|
||||||
Goal: build a (very) small REST API that exposes to endpoints."
|
Goal: build a (very) small REST API that exposes to endpoints."
|
||||||
[& args]
|
[& args]
|
||||||
|
(let [{{port :port} :server} config]
|
||||||
(println "Initializing SQLite database...")
|
(println "Initializing SQLite database...")
|
||||||
(init-db!)
|
(init-db!)
|
||||||
(println "Starting server...")
|
(println "Ahoy! Yo-ho-ho API starting on port" port)
|
||||||
(http-server/run-jetty app {:port 3000 :join? false})
|
(http-server/run-jetty app {:port port})))
|
||||||
(println "Ahoy! Yo-ho-ho API running on port 3000"))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user