CodingWithLuke
CodingWithLuke
Explore posts from servers
Aarktype
Created by CodingWithLuke on 2/28/2025 in #questions
Is there a good way to use an array of fields mapped from an object into array as string literals?
So probably really simple and I am just missing something. I am trying to achieve the following:
export const SCOPES = {
user: {
can_edit: "can_edit",
},
organiser: {
can_edit: "can_edit",
},
event: {
can_edit: "can_edit",
}
} as const;

const test = Object.values(SCOPES.user).map((scope) => `'${scope}'`);

export const user = type({
"...": permissionBase,
type: "'user'",
scopes: test
});
export const SCOPES = {
user: {
can_edit: "can_edit",
},
organiser: {
can_edit: "can_edit",
},
event: {
can_edit: "can_edit",
}
} as const;

const test = Object.values(SCOPES.user).map((scope) => `'${scope}'`);

export const user = type({
"...": permissionBase,
type: "'user'",
scopes: test
});
Not sure if this is possible but I may be missing something? The issue obviously comes in that its not a as const. But trying to figure out how I can achieve something like that. In this case its supposed to be an array of those strings.
5 replies
Aarktype
Created by CodingWithLuke on 2/26/2025 in #questions
How to choose "one of" in a type?
Hi there!
export const user_find_one_controller_input = type({
"_id?": userApi.schema.user.get("_id"),
"_email?": userApi.schema.user.get("email")
});
export const user_find_one_controller_input = type({
"_id?": userApi.schema.user.get("_id"),
"_email?": userApi.schema.user.get("email")
});
For example here I am wanting to have either or as an object. So saying that if there is no _id then there has to be an "email" and visa versa. Not sure how to achieve this Thanks!
21 replies
BABetter Auth
Created by CodingWithLuke on 2/26/2025 in #help
How to return custom session with modified DB fields
No description
5 replies
BABetter Auth
Created by CodingWithLuke on 2/26/2025 in #bug-reports
Getting a 404 on useSession and unable to use Svelte Store
No description
5 replies