for my fulcro application, my understanding is i'll need a server of some kind set up.
the fulcro template uses postgres, but for now I just want to get a running production instance without adding on a database.
I see in the book that http-kit
is mentioned, would that be an appropriate tool for my use case?
> the main thing is my clj and cljc files for my revolvers I do not understand what the problem is. > making a mock server You don't need that. For example start with fulcro template but replace Postgres with a simple atom holding a map. That will be your (not-persistent) DB. Or do what the Book does and run this and pathom in the browser, if you do not want to bother with a server at all (other then serving static files).
yeah a map is what i've been using to play around with resolvers. however when we build for production my understanding is the jar expects to run on a server set up in postgres. so the problem I'm trying to understand is how to appropriately replace postgres in that context, I think. that's why I asked about http kit. it's simple enough in dev, since you just spin up the shadow-cljs server. translating that into production has not been quite so easy for me.
PostgreSQL is a server process. That has nothing at all to do with Fulcro in front or back end (in terms of infra)
PSQL can run one same machine in small infra, or in a dedicated cluster on larger infra
it’s just a network connection via JVM JDBC…again, nothing at all to do with Fulcro
it’s just a database
JAR is a zip file containing code. Jar runs in JVM. That JVM could be running on a dedicated machine, a Docker container, Datomic Ions on an EC2….whatever. It’s a “machine”. Database is another box in the infra diagram.
could be same same “box” could be different “box”.
Resolvers are units of construction for the Pathom library. Each unit of code describes how to “resolve” an edge of your data graph, and you write the body. The body has to query whatever database you use (in this case PSQL over a network connection, possibly localhost loopback) to fulfill that requirement.
But the backend is not required. You can have all the pathom resolvers (the backend) running on js.
If you don't have backend then you don't need http communication
> psql is its own thing that has a db and server component no, Postgres does not have a DB and server component, Postgres is a DB, that works in client-server mode. Or did you mean something else? > the backend compiles to a jar. > but you still need an http server to communicate requests right? the jar is executable and spins up its own HTTP server, see https://github.com/fulcrologic/fulcro-template/blob/master/src/main/app/server_components/http_server.clj#L14 And as @jmayaalv writes, you can run Fulcro fully in the browser, Pathom included.
The JAR contains an embedded HTTP server (http-kit I think is the one I use in the template). Normally you will run that in a docker container or cloud instance of some kind, and put a load balancer in front of it (which will also supply SSL support) and proxy requests to this back-end http server. But, if you were to run the JAR on your own instance and have it use port 80 it would not need any other http server. The need for an additional http server has more to do with infra convenience (SSL cert support, load balancing, etc.).
ah! so I was on the right track then. I was confused as to if http-kit would be enough, but my understanding now from what you all are saying is that it is; assuming I'm not adding any other extra, external stuff in. I will look into this and http kit further and try to get this working. Thank you all for your patience with me!
Very likely if you want to run a web server (http/run-server) for your server side. Here is the sample code from Tony's Fulcro-3 tutorial:
(ns user
(:require [org.httpkit.server :as http]
[app.server :refer [middleware]]
[clojure.tools.namespace.repl :as tools-ns]
[taoensso.timbre :as log]))
;; make sure not to find things in place like resources
(tools-ns/set-refresh-dirs "src" "dev")
(defonce server (atom nil))
(defn start []
(let [result (http/run-server middleware {:port 3000})]
(log/info "Started web server on port 3000")
(reset! server result)
:ok))
(defn stop []
(when @server
(log/info "Stopped web server")
(@server)))
(defn restart []
(stop)
(log/info "Reloading code")
(tools-ns/refresh :after 'user/start))
Fulcro supports full stack operation, but it does not require a server. “long term storage” is typically modeled through the concept of a “remote”, which is usually http or websockets to some kind of server, often Ring-based. You can easily use a client-side storage mechanism (e.g. Datascript serialized into LocalStorage?) or even a “mock” server that does not persist over page reloads to model the server. A remote is just a map with a :transmit!
key that supports a lambda to do the operations of “remote” communication, but that is a complete abstraction.
The book, for example, does all of it’s full-stack demonstrations in-browser through such a “mock” remote.
thank you!
well the main thing is my clj and cljc files for my revolvers. that sounds like something that might be worth accomplishing if it makes the project simpler, but I'm not sure if it would. I've never tried making a mock server before. Is that worth pursuing for a small project?
What should I modify to use guardrails
in a shadow-cljs
project? In the readme there's a:
When you run a REPL or CLJS compiler, include the JVM option -Dguardrails.enabled.
but I invoke my repl from CIDER, and I'm not sure what I should changenot at all @yubrshen, thanks for the help!
can I enable it in some configuration file?
Check out this https://github.com/clojure-emacs/cider/issues/2396 I was able to add -A:dev option for Clojure REPL with
(setq cider-clojure-cli-global-options "A:cljs")
thanks @yubrshen! I tried doing:
(setq cider-clojure-cli-global-options "Dguardrails.enabled")
and also tried adding -Dguardrails.enabled
to the prompt with which I launch the repl:
[nREPL] Starting server via /run/current-system/sw/bin/npx shadow-cljs -Dguardrails.enabled -d nrepl/nrepl:0.8.3 -d cider/piggieback:0.5.2 -d refactor-nrepl:2.5.0 -d cider/cider-nrepl:0.25.5 server
None of these approaches worked for me. I also took a look at https://github.com/gothinkster/clojurescript-keechma-realworld-example-app/blob/master/guardrails.edn but I can find the mention of guardrails only in the guardrails.edn
file, I can't find how it's actually invokedIn the end, I got it working copying the config from https://github.com/fulcrologic/fulcro-template/blob/master/shadow-cljs.edn#L9-L10
keep in mind that, if it's not throwing, the error will be just a warning in the browser's console
@tony.kay would you accept PR to add :com.fulcrologic.rad.report/column-class
to report-options
or do you still want to wait with it a while?
@holyjak I’d prefer not to add it there. These should really be part of the rendering plugin’s options, since that renderer might support rendering the thing in any manner of ways (not just table). I realize “report” is table-centric in RAD “by default”, but I want to leave as much of the “chrome config” to the UI plugins…so I’d take a PR against rad SUI plugin 😄
Yeah, this is why I just haven’t acted. I have the same concern. Technically, though, RAD supports Native so a “class” really is a rendering artifact of HTML that isn’t tied to RAD core….but this is such a common case that it may really just deserve a core option.
Sure, go ahead and send a PR for the option with a docstring, just note that it is a HINT to a HTML render plugin.