summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreltrac <hi@eltr.ac>2026-10-10 09:46:44 +0800
committereltrac <hi@eltr.ac>2026-10-10 09:46:44 +0800
commit785b3a80e946b3a595a9d140ba277a448d9f38cf (patch)
treed33e19e27fa82417367daf4552ced998da018bb9
parentfb52ea77584a4c3c7703ac8b93095dae03f1552e (diff)
edn_storage, handler, core: decouple stroage conformity responsibility
- handler and core no longer care if storage is a valid vtable - use-store assert storage is valid before it was returned - AssertionError should be spotted while testing
-rw-r--r--src/weepinbell/core.clj3
-rw-r--r--src/weepinbell/storage/edn_storage.clj3
-rw-r--r--src/weepinbell/webserver/handler.clj3
3 files changed, 4 insertions, 5 deletions
diff --git a/src/weepinbell/core.clj b/src/weepinbell/core.clj
index c9cd78e..f97fffc 100644
--- a/src/weepinbell/core.clj
+++ b/src/weepinbell/core.clj
@@ -29,8 +29,7 @@
config (load-config)
;; Storage middle layer, a map of data-manipulating functions.
;; Supports various storage as long as the map conforms storage.spec.
- store (s/conform :weepinbell.storage.spec/vtable
- (edn/use-store (:data-path config)))
+ store (edn/use-store (:data-path config))
;; Hooks, a map of callback functions that processor calls
;; on certain events. Can be used for webhooks and more.
hooks (webhook/make-hooks config)
diff --git a/src/weepinbell/storage/edn_storage.clj b/src/weepinbell/storage/edn_storage.clj
index 50247fe..6a06c28 100644
--- a/src/weepinbell/storage/edn_storage.clj
+++ b/src/weepinbell/storage/edn_storage.clj
@@ -4,6 +4,8 @@
(:require [fast-edn.core :as edn]
[clojure.java.io :as io]
[weepinbell.utils.url :refer [get-domain get-target get-path url=]]
+ [clojure.spec.alpha :as s]
+ [weepinbell.storage.spec]
[clojure.string :refer [join]]))
(defn unload-data
@@ -88,6 +90,7 @@
;; make storage vtable
(def file-exists? #(.exists (io/file %)))
(defn use-store [datasource]
+ {:post [#(s/valid? :weepinbell.storage.spec/vtable %)]}
(when (not (file-exists? datasource))
(io/make-parents datasource)
(spit datasource ""))
diff --git a/src/weepinbell/webserver/handler.clj b/src/weepinbell/webserver/handler.clj
index cb29b23..9474b75 100644
--- a/src/weepinbell/webserver/handler.clj
+++ b/src/weepinbell/webserver/handler.clj
@@ -74,9 +74,6 @@
"Receive webmention channel, storage vtable and config map.
Returns an app handler."
[api-meta]
- (when (= :clojure.spec.alpha/invalid (:store api-meta))
- (println "Invalid storage. Check your database configuration or submit an issue.")
- (System/exit 1))
(-> (make-api api-meta)
make-handler
(wrap-resource "static")