Checkpoint on improvemenths.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
[compojure.route :as route]
|
||||
[clojure.java.io :as io]
|
||||
[clojure.string :as str]
|
||||
[auto-ap.db.invoices :as invoices]
|
||||
[auto-ap.parse :as parse]
|
||||
[ring.middleware.multipart-params :as mp]
|
||||
[ring.util.response :as response]
|
||||
@@ -12,32 +13,6 @@
|
||||
[ring.middleware.edn :refer [wrap-edn-params]]
|
||||
[clojure.java.jdbc :as j]))
|
||||
|
||||
(defn snake->kebab [s]
|
||||
(str/replace s #"_" "-"))
|
||||
|
||||
(defn kebab->snake [s]
|
||||
(str/replace s #"-" "_"))
|
||||
|
||||
(defn db->clj [x]
|
||||
(into {}
|
||||
(map
|
||||
(fn [[k v]]
|
||||
[(keyword (snake->kebab (name k))) v])
|
||||
x)))
|
||||
|
||||
(defn clj->db [x]
|
||||
(into {}
|
||||
(map
|
||||
(fn [[k v]]
|
||||
[(keyword (kebab->snake (name k))) v])
|
||||
x)))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(defroutes app-routes
|
||||
(GET "/" [] (response/resource-response "index.html" {:root "public"}))
|
||||
(GET "/api/invoices" []
|
||||
@@ -45,9 +20,13 @@
|
||||
:body (pr-str (invoices/get-all))
|
||||
:headers {"Content-Type" "application/edn"}})
|
||||
|
||||
(GET "/api/invoices/pending" []
|
||||
{:status 200
|
||||
:body (pr-str (invoices/get-pending))
|
||||
:headers {"Content-Type" "application/edn"}})
|
||||
|
||||
(POST "/api/invoices" {:keys [edn-params]}
|
||||
(invoices/insert-multi! (:rows edn-params))
|
||||
|
||||
{:status 200
|
||||
:body (pr-str (invoices/get-all))
|
||||
:headers {"Content-Type" "application/edn"}})
|
||||
|
||||
Reference in New Issue
Block a user