Fork me on GitHub
#luminus
<
2021-07-21
>
Jacob Rosenzweig02:07:10

Is there a simple way to add a camelCase -> kebab-case middleware into luminus for my POST requests? Right now I have something like this:

(def instance
  (m/create
    (-> m/default-options
        (update-in
          [:formats "application/transit+json" :decoder-opts]
          (partial merge time/time-deserialization-handlers))
        (update-in
          [:formats "application/transit+json" :encoder-opts]
          (partial merge time/time-serialization-handlers))
        (update-in
          [:formats "application/json" :encoder-opts]
          (partial merge #(name (csk/->camelCase %))))
        (update-in
          [:formats "application/json" :decoder-opts]
          (partial merge #(keyword (csk/->kebab-case %)))))))
But it's obviously not working.

Jacob Rosenzweig02:07:11

I almost had it! I didn't add the anonymous function to the right key.

(def instance
  (m/create
    (-> m/default-options
        (update-in
          [:formats "application/transit+json" :decoder-opts]
          (partial merge time/time-deserialization-handlers))
        (update-in
          [:formats "application/transit+json" :encoder-opts]
          (partial merge time/time-serialization-handlers))
        (update-in
          [:formats "application/json" :encoder-opts]
          (partial merge {:encode-key-fn #(name (csk/->camelCase %))}))
        (update-in
          [:formats "application/json" :decoder-opts]
          (partial merge {:decode-key-fn #(keyword (csk/->kebab-case %))})))))

rnandan27311:07:08

Created new luminus fullstack app, however the shadow-cljs watch app command shows up an error, Any ideas?

javahippie11:07:00

What error do you get? Which command exactly did you type?

rnandan27312:07:57

shadow-cljs watch app, it says cannot bind to port 9630, actually nothing is running on that port

rnandan27312:07:30

however shadow-cljs compile app runs, so it is a issue with port, where do we set another port?

javahippie15:07:25

Is the backend working (port 3000)? Just to check that the process is allowed to open ports at all

rnandan27311:07:36

this was created using lein new luminus +re-frame +http-kit

rnandan27316:07:52

Issue with lein script, updated to 2.9.6 and things started working