make datomic config dynamic
This commit is contained in:
parent
5245c9a2dd
commit
6878e11a4c
2 changed files with 9 additions and 6 deletions
|
|
@ -14,5 +14,7 @@
|
||||||
(defn get-config []
|
(defn get-config []
|
||||||
(->
|
(->
|
||||||
(static-config)
|
(static-config)
|
||||||
|
(assoc-in-not-nil [:datomic :storage-dir] (env :datomic-path))
|
||||||
|
(assoc-in-not-nil [:datomic :system] (env :datomic-env))
|
||||||
(assoc-in-not-nil [:jetty :host] (env :host))
|
(assoc-in-not-nil [:jetty :host] (env :host))
|
||||||
(assoc-in-not-nil [:jetty :port] (safe-parse-int (env :port)))))
|
(assoc-in-not-nil [:jetty :port] (safe-parse-int (env :port)))))
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,18 @@
|
||||||
[clojure.set :as set]
|
[clojure.set :as set]
|
||||||
[datomic.client.api :as d]
|
[datomic.client.api :as d]
|
||||||
[malli.core :as m]
|
[malli.core :as m]
|
||||||
|
[snippets.infra.config :as config]
|
||||||
[taoensso.telemere :as t]))
|
[taoensso.telemere :as t]))
|
||||||
|
|
||||||
;; Initialize the Datomic Local client
|
;; Initialize the Datomic Local client
|
||||||
;; :system "dev" groups your databases in the "dev" system
|
;; :system "dev" groups your databases in the "dev" system
|
||||||
;; In production, you'd set :storage-dir to a persistent path
|
;; In production, you'd set :storage-dir to a persistent path
|
||||||
;; TODO: add save file location for prod
|
;; TODO: add save file location for prod
|
||||||
(def client (d/client {:server-type :datomic-local
|
|
||||||
:system "dev"}))
|
(def datomic-config (:datomic (config/get-config)))
|
||||||
|
|
||||||
|
(def client (d/client (merge {:server-type :datomic-local
|
||||||
|
:system "dev"} datomic-config)))
|
||||||
|
|
||||||
(def db-name "snippets")
|
(def db-name "snippets")
|
||||||
|
|
||||||
|
|
@ -102,7 +106,7 @@
|
||||||
[entity]
|
[entity]
|
||||||
(m/validate create-schema entity))
|
(m/validate create-schema entity))
|
||||||
|
|
||||||
(defn- put-snippets
|
(defn create-snippets
|
||||||
"Create new snippets in the database."
|
"Create new snippets in the database."
|
||||||
[snippets]
|
[snippets]
|
||||||
(t/log! {:level :info, :data {:slugs (map :slug snippets)}} "Saving new snippets to db")
|
(t/log! {:level :info, :data {:slugs (map :slug snippets)}} "Saving new snippets to db")
|
||||||
|
|
@ -112,9 +116,6 @@
|
||||||
(d/transact conn {:tx-data entities})
|
(d/transact conn {:tx-data entities})
|
||||||
(throw (ex-info "Invalid snippet entity" {:entities entities})))))
|
(throw (ex-info "Invalid snippet entity" {:entities entities})))))
|
||||||
|
|
||||||
(def create-snippets
|
|
||||||
(wrap-snippet-return put-snippets))
|
|
||||||
|
|
||||||
;; read
|
;; read
|
||||||
(defn- get-snippet-by-slug-from-db
|
(defn- get-snippet-by-slug-from-db
|
||||||
"Get a single snippet by its slug."
|
"Get a single snippet by its slug."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue