Fork me on GitHub
#yada
<
2016-08-30
>
dominicm10:08:39

Edge now uses the @(promise) technique

kardan12:08:37

What’s the state of using JWT for authentication? Seen sections in docs but not sure the functionality is there but no docs yet, or if it’s on the todo list.

frozenlock13:08:10

Where is the yada.yada/path-for described in https://juxt.pro/yada/manual/index.html#_resource_models ? I only see uri-for in the namespace...

frozenlock13:08:34

(And I don't want to use uri-for, because I would need to use vhost)

severed-infinity14:08:45

hey I am curious about :parameters :form I know a form can have multiple inputs but I am wondering about a single input that can be multiple e.g. :parameters {:form {:users [String]}} a long those lines?

severed-infinity14:08:06

nevermind, turns out that does just work

dominicm14:08:53

@frozenlock My answer probably wasn't clear enough. vhost conveniently provides a uri-for, and puts it into the ctx.

dominicm14:08:14

Anything which puts a :uri-for key into the ctx, that function will be called for you.

malcolmsparks14:08:12

@kardan: there are some jwt examples under dev/src in the yada repo. It's all working and used in prod

malcolmsparks14:08:11

@frozenlock: you have to use bidi's vhosts model to use yada/uri-for. Otherwise use bidi's path-for directly

frozenlock14:08:51

malcolmsparks : does path-for support yada resource ID? (I think I tried it a few days ago without much success.)

frozenlock14:08:57

I also understand that yada.path-for was removed in favor of uri-for.

kardan14:08:15

@malcolmsparks perfect - then I’ll dig in. Thanks

malcolmsparks14:08:51

@frozenlock It should do - are you wrapping your resources in yada/handler?

frozenlock15:08:22

Ah no, that must be it. I was using yada

malcolmsparks15:08:22

it shouldn't matter - you should be able to put in resources in your bidi structure, or wrap them in yada/handler -both cases should work

frozenlock15:08:20

It does seem to work with a minimal example... 😕 --- edit: I was wrong, I can't get it to work.

frozenlock15:08:41

What is the advantage of using vhosts over simply looking the scheme and host in the ctx?

severed-infinity16:08:02

I had asked in the datomic channel but thought I’d ask here too hey guys I’ve this query

(defn mult-lookup-user [db phones]
  (let [result (d/q '[:find ?e ?phone
                      :in $ [?phone ...]
                      :where [?e :user/phone ?phone]] db phones)]
    (map second result)))

(mult-lookup-user (d/db connect) ["0862561423" "0877654321"])
where it will return only existing phones, and running it standalone works perfectly but my issues is using with a yada resource, the important section below
{:post {:parameters {:form {:users [String]}
                                  :body [String]}
            :consumes  #{"application/json" "application/x-www-form-urlencoded;q=0.9"}
            :produces   #{"application/json" "application/edn"}
            :response   (fn [ctx]
                                    (let [users (or (get-in ctx [:parameters :body])
                                                           (get-in ctx [:parameters :form :users]))]
                                                         
                                          (when-let [valid-users (mult-lookup-user (d/db connect) users)]
                                                (println "valid" valid-users)
                                                (if (seq? valid-users)
                                                    (json/generate-string valid-users)))))}}
using the same input as when called standalone returns an empty list, but if I include just one value (valid of course) it returns that singular result. Can any help explain this issue?

severed-infinity17:08:49

not sure if it was an error or mistake on my behalf but discovered that doing {:form {:users [String]}} causes an array of input to be transformed into array with a singular value of all the values joined. but the solution was to (str/split (first users) #",”)