Stuart B
Explore posts from serversBABetter Auth
•Created by Stuart B on 4/23/2025 in #help
Multiple database queries for getSession()
Im passing a kysely instance, which I thought wasn't using an adapter? If I just pass a dialect, are joins supported then?
4 replies
BABetter Auth
•Created by Filippo on 4/23/2025 in #help
How to log in from the server
Looks like you're using sveltekit? If so, just add headers:request.headers as an option to the signInEmail config in the form action.
12 replies
BABetter Auth
•Created by Filippo on 4/23/2025 in #help
How to log in from the server
That won't be setting a session cookie, so your next navigation doesn't know about the session. Try passing headers:request.headers as an option.
12 replies
BABetter Auth
•Created by Stuart B on 4/17/2025 in #help
How to acces ID token returned by oAuth provider
I looked at that but it doesn't look like I can access things from the account table. Thanks for the suggestion, though.
I can do it by querying the db myself and adding the data to the session object as a custom field.
But I've discovered that (at least using drizzle) it already does 2 db queries each time, one for session and one for user, rather than a single joined query.
If I want the idToken from the account table, that's 3 separate db queries each time a session is checked, which is excessive.
I decided to go back to my Lucia auth and fix the minor issue I had. That allows me to get all the info I need with a single query.
4 replies
BABetter Auth
•Created by Omicrxn on 4/17/2025 in #help
Unclear on how to handle session and cookies in sveltekit
I've just had a similar issue. Make sure that in +hooks.server.ts you exclude /api/auth/ from any redirect. Otherwise when the oAuth provider does it's callback, it just gets redirected back to the login page, rather than to the better-auth api. That wasted me 3 hours!
9 replies
Aarktype
•Created by Stuart B on 3/4/2025 in #questions
Is it possible to define a type that does this?
Damn, that's so obvious, thanks! It didn't occur to me to .pipe the entire type like that. I was trying to apply the morph within the definition of the '"approved" key instead. Much simpler this way!
5 replies
Aarktype
•Created by Stuart B on 9/5/2024 in #questions
Any way to tell if a custom description has been provided?
If you're just wanting to define a schema then serialise and store that in a db, it works really well. You just read the data out the db and pass the resulting object into the type() function. Dead easy.
I've had a few difficulties and frustrations but that's all been using morphs and defaults.
14 replies
Aarktype
•Created by Cobain on 10/9/2024 in #questions
Function which receives a arktype's 'type'
Good to know!
13 replies
Aarktype
•Created by Cobain on 10/9/2024 in #questions
Function which receives a arktype's 'type'
try:
13 replies
Aarktype
•Created by Stuart B on 9/30/2024 in #questions
Identifying a Date value in an object type
I'm feeling guilty about causing you extra work now. But it is very much appreciated.
39 replies
Aarktype
•Created by Stuart B on 9/30/2024 in #questions
Identifying a Date value in an object type
Thanks,good to know. I've just about got it working with the map() api now, where it seems to work as expected.
39 replies
Aarktype
•Created by Stuart B on 9/30/2024 in #questions
Identifying a Date value in an object type
Seems like the problem wasn't what I thought it was.
I tried value.json and I still have an issue.
I'm iterating through a type (validator) using
And using
to get the value.
This works for number, boolean, string. But when I try it with a Date, value.json returns
No sign of 'Date' anywhere.
Maybe I'll have to try rewriting using .map(). (I tried before, but Typescript was giving me all sorts of problems I couldn't work out, so I stuck with the old .internal.distribute)
39 replies
Aarktype
•Created by Stuart B on 9/30/2024 in #questions
Identifying a Date value in an object type
Sorry, misunderstanding. I'm not trying to identify a date ibject, I'm trying to identify a type that allows a date object.
39 replies
Aarktype
•Created by Stuart B on 9/25/2024 in #questions
Post-morph constraints not checked if constraints not met on another property
Chipping in as a fairly ignorant user (of ArkType) here... I'd imagine a lot of people wanting to use ArkType as part of a form validation process. With the current behaviour, you can't get full errors to your app user about what's wrong with an input form using the obvious approach. You end up with an error or two for the user to correct, they do so, and then another one pops up.
It seems the only way round that is to not use ArkType to do the data transformation from FormData strings into numeric. I don't think it's the behaviour most people would expect and is bound to cause a bunch of confusion.
If it stays the way it is, I think the docs should highlight this issue and maybe provide a suggested approach for form validation, as it's such a common use case.
188 replies
Aarktype
•Created by PIat on 9/4/2024 in #questions
Converting Zod to Arktype
That's great David, thanks!
I think it would be worth clearly mentioning in the docs that defaults refer to the input type, regardless of where you assign them. It's pretty obvious with 'string="off"', but if you add a .default() after the morph, I expect some people will assume that it applies to the morphed type.
Also, something like type('string|boolean=false') doesn't work. If there is no value passed then false as a default is not applied. If that's intentional (and I can see why it's a weird thing to do), then should it give a type error in the editor, rather than just ignore it?
174 replies
Aarktype
•Created by PIat on 9/4/2024 in #questions
Converting Zod to Arktype
It is such a relief that it wasn't me being an idiot!
174 replies
Aarktype
•Created by PIat on 9/4/2024 in #questions
Converting Zod to Arktype
Hi @ArkDavid , just to close this off, is the above example the way I need to go with this, or is there an approach that doesn't require 2 preprocess steps? I'm happy with either answer.
And sorry for my ignorance, if that's what it is. You're doing a very impressive job with Arktype!
174 replies
Aarktype
•Created by PIat on 9/4/2024 in #questions
Converting Zod to Arktype
I'm still missing something.
The below is the simplest example of what I want to do. This works, but it requires me to generate 2 preprocessing types, one to make sure there is a string value present and the second to transform the string value to a Boolean.
I can't get my head around why that can't be combined into one preprocessing step.
It seems like adding the 'string="off"' default to the second preprocess type should work, but it just ignores it. And I can't put the logic in the morph, as the morph doesn't run if it doesn't get a string value. Maybe I just have to accept "that's just the way it is, deal with it"!
It seems like adding the 'string="off"' default to the second preprocess type should work, but it just ignores it. And I can't put the logic in the morph, as the morph doesn't run if it doesn't get a string value. Maybe I just have to accept "that's just the way it is, deal with it"!
174 replies