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:
2026-01-31 02:39:56 +01:00
parent 78948fd017
commit 3f561ab70e

View File

@@ -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]
(println "Initializing SQLite database...") (let [{{port :port} :server} config]
(init-db!) (println "Initializing SQLite database...")
(println "Starting server...") (init-db!)
(http-server/run-jetty app {:port 3000 :join? false}) (println "Ahoy! Yo-ho-ho API starting on port" port)
(println "Ahoy! Yo-ho-ho API running on port 3000")) (http-server/run-jetty app {:port port})))