Shoodey
Shoodey
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Shoodey on 6/17/2023 in #questions
Next 13 + Vercel (+ axiom?), how to log?
2 replies
TTCTheo's Typesafe Cult
Created by Shoodey on 6/9/2023 in #questions
How to see NextJS logs on Vercel/Axiom/BetterStack?
I have an next 13 app deployed with an endpoint api/dostuff/route.ts that is a simple GET method that returns a JSON and logs message using console.log() when deploying to Vercel and having the Logs page open, I only see HTTP request logs but no runtime/functions logs. I have also added integrations to both Axiom and BetterStack (Logtail) to no avail. Any ideas please?
3 replies
TTCTheo's Typesafe Cult
Created by Shoodey on 5/8/2023 in #questions
Good Role-Based Access Control (RBAC) package?
Heyah, Are there any good recommendation for an rbac package that handles roles and permission from DB/ORM/X? Something like what exists in Laravel's ecosystem with API for user.can(permission) user.has(role)? I need this for some prototyping down the line and checking before I implement my own.
2 replies
TTCTheo's Typesafe Cult
Created by Shoodey on 2/16/2023 in #questions
Send large data (~5MB) to trpc backend
I need to build a feature that reads sqlite files in memory, my idea is to upload the file, parse it and pass it to my trpc backend that will create an in memory sqlite db to perform some queries. However, it seems passing large payloads takes ages (never finished) even locally, im not sure if trpc is not equipped to handle huge payloads. Please share if you have a solution or even a better way to do it. NOTE: I cant have a single db - each use can upload their own sqlite db file TLDR: how to upload a sqlite dump & perform queries on it
21 replies
TTCTheo's Typesafe Cult
Created by Shoodey on 1/28/2023 in #questions
Refetch minimum duration?
I wish to always keep data up to date and I use
{
refetchOnMount: true,
refetchOnWindowFocus: true,
refetchOnReconnect: true,
}
{
refetchOnMount: true,
refetchOnWindowFocus: true,
refetchOnReconnect: true,
}
Is it possible to set a minimum elapsed time before this is triggered? Yes, refetch on alt-tab but only if last refetch was a minute ago? I dont want users to abuse my API
3 replies
SIASapphire - Imagine a framework
Created by Shoodey on 1/25/2023 in #sapphire-support
Is Sapph.xyz bot related to this project/community?
Asking because of the name resemblence and i dont seem to find it in the server's bot list - is it in any way related (owner, uses sapphirejs, etc..) or just a name similarity?
6 replies
TTCTheo's Typesafe Cult
Created by Shoodey on 1/24/2023 in #questions
trpc call inside getServerSideProps?
(create-t3-turbo) I have a dynamic route for users' stuff, stuff/xyz they can they go to stuff/xyz/doStuff or stuff/xyz/doOtherStuff I need to validate xyz that it exists in my DB - then redirect to 404 if fails, so far ive done it with prisma client directly (inspired from zapdos kinda)
export const getServerSideProps: GetServerSideProps = async ({ params }) => {
if (!params || !params.xyz || typeof params.xyz !== "string") {
return {
notFound: true,
};
}

const stuff = await prisma?.stuff.findFirst({
where: {
xyz: params.xyz,
},
});

if (!stuff) {
return {
notFound: true,
};
}

return {
props: {
stuff: transformer.serialize(stuff).json,
},
};
};
export const getServerSideProps: GetServerSideProps = async ({ params }) => {
if (!params || !params.xyz || typeof params.xyz !== "string") {
return {
notFound: true,
};
}

const stuff = await prisma?.stuff.findFirst({
where: {
xyz: params.xyz,
},
});

if (!stuff) {
return {
notFound: true,
};
}

return {
props: {
stuff: transformer.serialize(stuff).json,
},
};
};
which works fine tbh - but i dont like how i need to import { Stuff } from ".prisma/client"; for my prop type and how im not using trpc for this (tbh) - is there a way to use trpc here or simply a better way? does it make sense to just trpc in client and redirect on useEffect + useRouter?
15 replies
TTCTheo's Typesafe Cult
Created by Shoodey on 1/23/2023 in #questions
How to App.getInitialProps in CT3A?
Heyah - Im trying to use jotai to set an atom read from cookie (sidebar state and color scheme) but I have no clue if Im doing it with typesafety and passing the right session prop
const MyApp = ({
Component,
pageProps: { session, showSidebar, ...pageProps },
}: AppProps<{ session: Session | null; showSidebar: boolean }>) => {
const setShowSidebar = useSetAtom(showSidebarAtom);

useEffect(() => {
setShowSidebar(showSidebar);
console.log(showSidebar);
}, [setShowSidebar, showSidebar]);

return (
<SessionProvider session={session}>
<Component {...pageProps} />
</SessionProvider>
);
};

MyApp.getInitialProps = async (appContext: AppContext) => {
const ctx = appContext.ctx;

const appProps = await App.getInitialProps(appContext);
const session = await getSession({ req: ctx.req });

const showSidebarCookie = getCookie("showSidebar", ctx);
const showSidebar =
showSidebarCookie === undefined ? true : showSidebarCookie;

return {
...appProps,
pageProps: {
session,
showSidebar,
},
};
};
const MyApp = ({
Component,
pageProps: { session, showSidebar, ...pageProps },
}: AppProps<{ session: Session | null; showSidebar: boolean }>) => {
const setShowSidebar = useSetAtom(showSidebarAtom);

useEffect(() => {
setShowSidebar(showSidebar);
console.log(showSidebar);
}, [setShowSidebar, showSidebar]);

return (
<SessionProvider session={session}>
<Component {...pageProps} />
</SessionProvider>
);
};

MyApp.getInitialProps = async (appContext: AppContext) => {
const ctx = appContext.ctx;

const appProps = await App.getInitialProps(appContext);
const session = await getSession({ req: ctx.req });

const showSidebarCookie = getCookie("showSidebar", ctx);
const showSidebar =
showSidebarCookie === undefined ? true : showSidebarCookie;

return {
...appProps,
pageProps: {
session,
showSidebar,
},
};
};
18 replies
SIASapphire - Imagine a framework
Created by Shoodey on 1/9/2023 in #sapphire-support
Button handler not triggering
Heyah @Helpers I basically added a button handler from https://www.sapphirejs.dev/docs/Guide/application-commands/interaction-handlers/buttons in /listeners and changed the example's button ID with the one from
const buttonRow = new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
.setCustomId("foo")
.setLabel("do stuff")
.setStyle(ButtonStyle.Primary),
);
const buttonRow = new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
.setCustomId("foo")
.setLabel("do stuff")
.setStyle(ButtonStyle.Primary),
);
but interaction just fails on click and im not too sure how to debug this - nothing else happens on logs beside Loaded 26 listeners :/ Any idea how to debug and maybe even fix?
19 replies
TTCTheo's Typesafe Cult
Created by Shoodey on 1/7/2023 in #questions
T3 + sockets?
I've been working with https://github.com/trpc/examples-next-prisma-websockets-starter which works just fine but I need a channel/room implementation with I believe socket.io provides, is there any existing repos that use this? with preferably WSS attaching to trpc's server 🙂
44 replies
TTCTheo's Typesafe Cult
Created by Shoodey on 1/5/2023 in #questions
How to make a trpc request wait on another hook
I basically have a state that is populated from a query param then an API call (i used context before and now jotai) but it is critical to populate that state first before issuing a following trpc call that will fetch something.
// store.ts
export const currentGuildAtom = atom<DiscordGuildProfile | null>(null);

// page.tsx
const guild = useAtomValue(currentGuildAtom);

const { data: textChannels } =
trpc.guildChannels.getGuildTextChannels.useQuery({
guildId: guild.id,
});
// store.ts
export const currentGuildAtom = atom<DiscordGuildProfile | null>(null);

// page.tsx
const guild = useAtomValue(currentGuildAtom);

const { data: textChannels } =
trpc.guildChannels.getGuildTextChannels.useQuery({
guildId: guild.id,
});
I need to initialize the state at null since it could actually be that where i manage that case by redirecting elsewhere. but if I hit this page, the state is populated but too early for trpc to handle it, and since hooks cannot live inside useEffect, I dont see a way to handle this, is there a way to suspend the trpc hook until I validate that guild is not null? or another workaround?
9 replies
TTCTheo's Typesafe Cult
Created by Shoodey on 12/27/2022 in #questions
How to fix session info re-rendering on page reload
Hey all, I use t3 for this app and I wonder if there is a way to fix the text re-rendering whenever i refresh the page, especially for the login/logout side - this uses trpc, next-auth and next 13
3 replies
TTCTheo's Typesafe Cult
Created by Shoodey on 12/24/2022 in #questions
Could someone help me debug this error?
../../packages/auth/src/auth-options.ts(19,22): error TS2339: Property 'id' does not exist on type '{ name?: string | null | undefined; email?: string | null | undefined; image?: string | null | undefined; }'. Context: Turborepo based on create-t3-turbo, I got the right prisma schema but im not sure where else to look
4 replies