netwrx
netwrx
Explore posts from servers
DTDrizzle Team
Created by netwrx on 4/18/2024 in #help
is it possible to do conditional relational queries?
for example, i only want to retrieve the author object if their profile is public (a boolean on a user object)
export const users_relations = relations(users_table, ({ many }) => ({
posts: many(posts_table),
}));

export const posts_relations = relations(posts_table, ({ one }) => ({
author: one(users_table, {
fields: [posts_table.owner_id],
references: [users_table.id],
}),
}));
export const users_relations = relations(users_table, ({ many }) => ({
posts: many(posts_table),
}));

export const posts_relations = relations(posts_table, ({ one }) => ({
author: one(users_table, {
fields: [posts_table.owner_id],
references: [users_table.id],
}),
}));
4 replies
NNuxt
Created by netwrx on 3/29/2024 in #❓・help
No session created - nuxt auth utils
export default oauth.discordEventHandler({
config: {
emailRequired: false,
profileRequired: true,
scope: ["guilds"],
},
async onSuccess(event, { user, tokens }) {
console.log(user.username);
await setUserSession(event, {
user: {
username: user.username,
},
});
return sendRedirect(event, "/");
},
// Optional, will return a json error and 401 status code by default
onError(event, error) {
console.error("Discord OAuth error:", error);
return sendRedirect(event, "/");
},
});
export default oauth.discordEventHandler({
config: {
emailRequired: false,
profileRequired: true,
scope: ["guilds"],
},
async onSuccess(event, { user, tokens }) {
console.log(user.username);
await setUserSession(event, {
user: {
username: user.username,
},
});
return sendRedirect(event, "/");
},
// Optional, will return a json error and 401 status code by default
onError(event, error) {
console.error("Discord OAuth error:", error);
return sendRedirect(event, "/");
},
});
No cookies, and no session is set after a successful auth. Even logging the session directly afterwards shows good data and it was set. But nada.
47 replies
NNuxt
Created by netwrx on 3/27/2024 in #❓・help
useFetch and queries will not re-fetch with watch array of reactive values
const route = useRoute();

const page = ref<number>(0);
const category = ref<string>(route.query.category?.toString() || "");

const {
data: servers,
refresh: refreshServers,
pending: servers_pending,
} = useFetch("/api/v1/stuff/fetch/feed", {
query: { page: page.value, category: category.value },
watch: [page, category],
});
const route = useRoute();

const page = ref<number>(0);
const category = ref<string>(route.query.category?.toString() || "");

const {
data: servers,
refresh: refreshServers,
pending: servers_pending,
} = useFetch("/api/v1/stuff/fetch/feed", {
query: { page: page.value, category: category.value },
watch: [page, category],
});
Any help is appreciated 😄
18 replies
NNuxt
Created by netwrx on 3/26/2024 in #❓・help
Missing type definitions when using useFetch for a dynamic route
const route = useRoute();
const id = route.params.id;

const { data: stuff, pending: stuff_pending } = useFetch(
`/api/v1/stuff/fetch/${id}`
);
const route = useRoute();
const id = route.params.id;

const { data: stuff, pending: stuff_pending } = useFetch(
`/api/v1/stuff/fetch/${id}`
);
31 replies
NNuxt
Created by netwrx on 3/26/2024 in #❓・help
200+ requests on a SSR simple page
Like this is so silly, it's just a bunch of random crap like scripts fonts and icons. Is this just how ssr works?
8 replies