Fork me on GitHub
#pedestal
<
2020-11-08
>
jhowd22:11:59

does anyone have a pedestal app that uses re-frame for the frontend? I am wanting to browse a repo so I can trace though how it would work because I seem to be struggling with it on my own

simongray08:11:21

I get the struggle (modern full-stack web development is complicated), but something like Re-frame is completely orthogonal to whatever the backend web service is written in. The only job that Pedestal (or Compojure or whatever) should have is to serve an HTML page containing your compiled JS bundle and perhaps expose 1 or more backend endpoints for data exchange. What part are you struggling with?

simongray08:11:41

This is not Pedestal (it’s Compojure), but it might point you in the right direction: https://github.com/simongray/sino.study/blob/master/src/sinostudy/navigation/handler.clj#L73-L90 Basically, there is a single API endpoint for data exchange using Transit and then a single endpoint (a fallback endpoint for unmatched requests) which serves the HTML page itself. It also uses Compojure’s way to specify static resources as a separate “endpoint”.

souenzzo15:11:24

Hello @jonathan.howden You are usin #shadow-cljs or figwheel for cljs? If you are on #shadow-cljs :

;; shadow-cljs.edn [:builds :my-cool-project]
:output-dir       "target/my-cool-project"
:asset-path       "/my-cool-project"
:modules          {:my-client {:entries [...]}}
Then in your #pedestal service-map
::http/port 8080
::http/file-path     "target"
A handler for your "HTML"
(defn my-spa 
  [req]
  {:body " ... <script src='/my-cool-project/my-client.js'> ..."
   :headers {"Content-Type" "text/html"}
   :status 200})
Then your router (def routes #{["/spa" :get my-spa :route-name :my-spa ]})

jhowd17:11:59

thank you both! This is definitely helpful and gives me a good path to start down

souenzzo15:11:24

Hello @jonathan.howden You are usin #shadow-cljs or figwheel for cljs? If you are on #shadow-cljs :

;; shadow-cljs.edn [:builds :my-cool-project]
:output-dir       "target/my-cool-project"
:asset-path       "/my-cool-project"
:modules          {:my-client {:entries [...]}}
Then in your #pedestal service-map
::http/port 8080
::http/file-path     "target"
A handler for your "HTML"
(defn my-spa 
  [req]
  {:body " ... <script src='/my-cool-project/my-client.js'> ..."
   :headers {"Content-Type" "text/html"}
   :status 200})
Then your router (def routes #{["/spa" :get my-spa :route-name :my-spa ]})