Fork me on GitHub
#babashka
<
2021-08-10
>
dabrazhe12:08:50

What's the right way to call bb code from bb tasks? I'm resorting now to (shell "bb bbscript.clj")

borkdude13:08:30

@dennisa you can use (load-file "bbscript.clj")

borkdude13:08:14

or if you have the file on the classpath using :paths, then :requires ([thescriptdir.thescriptns])

👍 2
borkdude13:08:28

the latter assumes no side effects on the top level

michael zhou15:08:18

Hey @borkdude does bb support crux now?

borkdude15:08:57

What makes you think it does?

michael zhou16:08:57

I do not know. Hope bb will support. Crux is a great document and graph database

richiardiandrea17:08:04

There could be a crux pod working against the JSON api for sure 😉

💡 2
borkdude20:08:51

why not just use an http client in bb directly then?

borkdude20:08:07

or are you not talking about a JSON rest API?

richiardiandrea20:08:57

right, yeah probably an HTTP client is a better idea there

michael zhou00:08:16

Thank you very much! @borkdude @U0C8489U6 will try client.

deleted23:08:37

it's very cool that it supports an http server, just surprising that there's no routing layer (or maybe none easily port?)

borkdude08:08:56

Some reasons are: 1) Choice paralysis: compojure, reitit? 2) These routing libs aren't really small, e.g. compojure comes with deps like instaparse 3) HTTP apps aren't really the major use case for bb, perhaps. So far just a str/split in "/" and core.match could be sufficient for most of them.

dgb2310:08:20

Here is an example of core.match being used to dispatch on routes. Seems quite elegant and sufficient for many cases: https://github.com/prestancedesign/babashka-htmx-todoapp/blob/master/htmx_todoapp.clj#L178 Was posted in #announcements by @UFBL6R4P3 : https://clojurians.slack.com/archives/C06MAR553/p1628368949097900

👍 4
clojure-spin 4
🙌 2
2
2
borkdude10:08:41

I agree. People may not be used to this, but I think it's sufficient for the basic web app you will write with bb.

👍 4
2