read backend-host from config file
This commit is contained in:
parent
53acc339b3
commit
c4ff9a86b6
4 changed files with 9 additions and 18 deletions
1
config.edn
Normal file
1
config.edn
Normal file
|
|
@ -0,0 +1 @@
|
|||
{:backend-host "http://aemos:5008"}
|
||||
3
src/cli_cms/config.clj
Normal file
3
src/cli_cms/config.clj
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(ns cli-cms.config)
|
||||
|
||||
(def config (read-string (slurp "config.edn")))
|
||||
|
|
@ -2,12 +2,13 @@
|
|||
(:require
|
||||
[cli-cms.cli-utils :as utils]
|
||||
[clojure.string :as str]
|
||||
[cli-cms.config :refer [config]]
|
||||
[babashka.http-client :as http]
|
||||
[cheshire.core :as json]
|
||||
[babashka.process :refer [shell]]))
|
||||
|
||||
(defn create-snippet [{:keys [title slug markdown tags]}]
|
||||
(http/post "http://localhost:8080/api/snippet"
|
||||
(http/post (str (:backend-host config) "/api/snippet")
|
||||
{:headers {:content-type "application/json"}
|
||||
:body (json/encode {:title title :slug slug :markdown markdown :tags tags})}))
|
||||
|
||||
|
|
|
|||
|
|
@ -1,34 +1,20 @@
|
|||
(ns cli-cms.delete
|
||||
(:require
|
||||
[cli-cms.cli-utils :as utils]
|
||||
[cli-cms.config :refer [config]]
|
||||
[clojure.pprint :refer [pprint]]
|
||||
[babashka.http-client :as http]
|
||||
[cheshire.core :as json]))
|
||||
|
||||
;; (defn create-snippet [{:keys [title slug markdown tags]}]
|
||||
;; (http/post "http://localhost:8080/api/snippet"
|
||||
;; {:headers {:content-type "application/json"}
|
||||
;; :body (json/encode {:title title :slug slug :markdown markdown :tags tags})}))
|
||||
;;
|
||||
|
||||
(defn fetch-snippets []
|
||||
(let [res (http/get "http://localhost:8080/api/snippet?limit=25")]
|
||||
(let [res (http/get (str (:backend-host config) "/api/snippets?limit=25"))]
|
||||
(json/parse-string (:body res) true)))
|
||||
|
||||
(defn delete-snippet [id]
|
||||
(http/delete "http://localhost:8080/api/snippet" {:query-params {"id" id}}))
|
||||
(http/delete (str (:backend-host config) "/api/snippet") {:query-params {"id" id}}))
|
||||
|
||||
(defn run []
|
||||
(let [snippets (fetch-snippets)
|
||||
selected-slug (utils/select (map :slug snippets))
|
||||
selected-snippet (first (filter #(= (:slug %) selected-slug) snippets))]
|
||||
(delete-snippet (:id selected-snippet))))
|
||||
|
||||
;; (some #(when (> % 5) %) [1 3 7 2])
|
||||
;; (some #(when) (utils/select (map :slug snippets)))))
|
||||
;; (utils/print "Please enter a title:")
|
||||
;; (println "Please enter a title:")
|
||||
;; (println (format "TODO: create post with title: %s and slug %s" title slug))
|
||||
;; (println tags)
|
||||
;; (println markdown)
|
||||
;; (create-snippet {:title title :slug slug :markdown markdown :tags tags})))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue