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])
|
||||
(:gen-class))
|
||||
|
||||
;; Configuration --------------------------------------------------
|
||||
(def config
|
||||
{:db {:dbtype "sqlite" :dbname "yohoho.db"}
|
||||
:server {:port 3000}})
|
||||
|
||||
|
||||
;; Data schema ----------------------------------------------------
|
||||
;; Malli schemas for validation
|
||||
@@ -27,7 +32,7 @@
|
||||
|
||||
|
||||
;; Database stuff -------------------------------------------------
|
||||
(def db {:dbtype "sqlite" :dbname "yohoho.db"})
|
||||
(def db (:db config))
|
||||
|
||||
(defn init-db!
|
||||
"Create database structure if needed"
|
||||
@@ -135,8 +140,8 @@
|
||||
"HolidayPirates take-home assignement.
|
||||
Goal: build a (very) small REST API that exposes to endpoints."
|
||||
[& args]
|
||||
(println "Initializing SQLite database...")
|
||||
(init-db!)
|
||||
(println "Starting server...")
|
||||
(http-server/run-jetty app {:port 3000 :join? false})
|
||||
(println "Ahoy! Yo-ho-ho API running on port 3000"))
|
||||
(let [{{port :port} :server} config]
|
||||
(println "Initializing SQLite database...")
|
||||
(init-db!)
|
||||
(println "Ahoy! Yo-ho-ho API starting on port" port)
|
||||
(http-server/run-jetty app {:port port})))
|
||||
|
||||
Reference in New Issue
Block a user