Fork me on GitHub
Lyn Headley02:12:03

Is there a recommended way of creating and destroying short-lived databases used for holding test fixtures?

Lyn Headley02:12:24

Maybe (xt/start-node {}) is all I need

☝️ 1

I am playing around with hitting endpoints on the server… essentially creating an API that doesn’t use credentials for now. The app is on DO at the moment. A GET worked great (which calls a function that does something arbitrary on the server). However, a POST call returns a 403/<h1>Invalid anti-forgery token</h1>. Probably the right question is: how would I create an API for a Biff app so that other things can trigger events on the server (hardware buttons on Arduinos or the like/scripts on devices/etc). Can I issue credentials to users to make calls? In the case of, say, an Arduino I could bake the credential into the calls the device makes. Presumably a user would have an account on a Biff app first, then one would issue a credential that is tied to them. Just brainstorming here. I’m a fan of Swagger UI docs, btw… but that is outside the scope of this question but mentioning it since, down the road, it would be sweet to have automatic interactive documentation for the endpoints. I realize credentials and the anti forgery issue are probably separate ones. My immediate quick and dirty need is to be able to POST form data to a Biff app on DO but not from the context of a logged in user on a web page.

Jacob O'Bryant03:12:44

Put the routes under an :api-routes key in your features map instead of the :routes key. That'll disable the csrf token check.


haha… 2000 word question, one line solution.

🙂 1
Jacob O'Bryant03:12:26

You could add a :user/access-token attribute and store the random token there when the user clicks "generate token" or whatever. Then make some wrap-api-token middleware that checks the Authorization header for the existence of the token, and use it to wrap all the :api-routes routes.

Jacob O'Bryant03:12:04

I think reitit might have stuff for generating swagger docs?


It does I’m pretty sure, and Biff uses reitit. It’s all wonderfully possible!


FYI, if you are unfortunate enough to have a custom _JAVA_OPTIONS env variable (I've set it to force java into using ~/.config/java instead of ~/.java). Repro and suggested solution in:thread:


A warning appears at the beginning of the output of java -version, which trips up the indexes 😞 For example:

Picked up _JAVA_OPTIONS: -Djava.util.prefs.userRoot=/home/pavlos/.config/java
openjdk version "19.0.1" 2022-10-18
Replacing (nth 2) with
(as-> $ (drop-while #(not= % "version") $))
(nth 1)
seems to be working for me and depending on the version number being right after "version" seems ok to me (still kinda flaky but probably less likely to break) Would you be interested in a PR?

Jacob O'Bryant22:12:55

A PR would be great--sorry about that!


Nah, installation was too easy before anyway 😉 (PR on the way)

🙂 1

Wow, I was about to give you a proper repro case in case you wanted to test it on another machine but thanks for merging so quickly :the_horns:

Jacob O'Bryant22:12:20

haha no worries, already tested on my machine


cool, thanks 🙂

Jacob O'Bryant22:12:40

the new script is on now, so the regular new project command should work

😎 1