fulcro

Book: http://book.fulcrologic.com, Community Resources: https://fulcro-community.github.io/, RAD book at http://book.fulcrologic.com/RAD.html
Mr. Savy 2021-02-01T00:21:13.192400Z

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?

Jakub Holý 2021-02-01T09:34:04.197700Z

> 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).

Mr. Savy 2021-02-01T17:14:34.198200Z

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.

tony.kay 2021-02-01T17:26:46.198500Z

PostgreSQL is a server process. That has nothing at all to do with Fulcro in front or back end (in terms of infra)

tony.kay 2021-02-01T17:27:17.198700Z

PSQL can run one same machine in small infra, or in a dedicated cluster on larger infra

tony.kay 2021-02-01T17:27:38.198900Z

it’s just a network connection via JVM JDBC…again, nothing at all to do with Fulcro

tony.kay 2021-02-01T17:27:41.199100Z

it’s just a database

tony.kay 2021-02-01T17:28:41.199300Z

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.

tony.kay 2021-02-01T17:28:54.199500Z

could be same same “box” could be different “box”.

tony.kay 2021-02-01T17:30:33.199800Z

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.

2021-02-02T07:27:31.209200Z

But the backend is not required. You can have all the pathom resolvers (the backend) running on js.

2021-02-02T07:27:57.209400Z

If you don't have backend then you don't need http communication

Jakub Holý 2021-02-02T07:55:41.209900Z

> 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.

tony.kay 2021-02-03T02:55:22.226400Z

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.).

Mr. Savy 2021-02-03T05:28:49.226600Z

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!

✅ 1
yubrshen 2021-02-01T01:24:07.194200Z

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))

tony.kay 2021-02-01T04:31:45.194500Z

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.

Mr. Savy 2021-02-01T04:51:00.194700Z

thank you!

Mr. Savy 2021-02-01T05:32:38.196200Z

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?

william 2021-02-01T18:59:24.201200Z

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 change

william 2021-02-04T17:10:02.244300Z

not at all @yubrshen, thanks for the help!

william 2021-02-01T19:02:46.201300Z

can I enable it in some configuration file?

yubrshen 2021-02-01T19:39:08.203700Z

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")

william 2021-02-01T20:14:25.204Z

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 invoked

william 2021-02-01T20:47:49.204300Z

In the end, I got it working copying the config from https://github.com/fulcrologic/fulcro-template/blob/master/shadow-cljs.edn#L9-L10

william 2021-02-01T20:48:17.204600Z

keep in mind that, if it's not throwing, the error will be just a warning in the browser's console

Jakub Holý 2021-02-01T21:54:33.205600Z

@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?

tony.kay 2021-02-01T22:47:00.207600Z

@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 😄

👍 1
tony.kay 2021-02-03T02:45:57.225300Z

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.

👍 1
tony.kay 2021-02-03T02:46:39.225500Z

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.