gnarley_farley.
gnarley_farley.
Explore posts from servers
TTCTheo's Typesafe Cult
Created by gnarley_farley. on 7/3/2024 in #questions
Have to refresh typescript server after pnpm -ui add of components (TURBOREPO)
For some reason i have to refresh my typescript server after every component I add (otherwise squiggly lines) . Does anyone else have to do this?
2 replies
PPrisma
Created by gnarley_farley. on 7/2/2024 in #help-and-questions
How to use migrate when having a directurl and normal url
I get this error Please make sure your database server is running at db.caowreskbcgzoajwwjvy.supabase.co:5432.
2 replies
TTCTheo's Typesafe Cult
Created by gnarley_farley. on 5/7/2024 in #questions
How do i debug my expo app
No description
2 replies
TTCTheo's Typesafe Cult
Created by gnarley_farley. on 5/6/2024 in #questions
Error when trying to spin up turbo repo
No description
5 replies
PPrisma
Created by gnarley_farley. on 4/8/2024 in #help-and-questions
Paying for this service but can't login. On multiple accounts now
No description
18 replies
TTCTheo's Typesafe Cult
Created by gnarley_farley. on 2/2/2024 in #questions
How can i get session.user.id from nextauth when using the edge runtime?
I need to pass the session.user.id into my prismadb from the edge runtime. Any ideas?
2 replies
TTCTheo's Typesafe Cult
Created by gnarley_farley. on 1/17/2024 in #questions
I has a long-running server task. I want to update my db afterwards. It's on the edge.
Should I use TRPC on the edge runtime or prisma or update by supabase db direct? what's the cleanest way to do this. I don't want to do it in my component.
2 replies
TTCTheo's Typesafe Cult
Created by gnarley_farley. on 1/5/2024 in #questions
Trying to get shadcn themes to work. How can i dynamically adjust the
@layer base { :root { --background: 0 0% 100%; --foreground: 20 14.3% 4.1%; --card: 0 0% 100%; --card-foreground: 20 14.3% 4.1%; --popover: 0 0% 100%; --popover-foreground: 20 14.3% 4.1%; --primary: 24.6 95% 53.1%; --primary-foreground: 60 9.1% 97.8%; --secondary: 60 4.8% 95.9%; --secondary-foreground: 24 9.8% 10%; --muted: 60 4.8% 95.9%; --muted-foreground: 25 5.3% 44.7%; --accent: 60 4.8% 95.9%; --accent-foreground: 24 9.8% 10%; --destructive: 0 84.2% 60.2%; --destructive-foreground: 60 9.1% 97.8%; --border: 20 5.9% 90%; --input: 20 5.9% 90%; --ring: 24.6 95% 53.1%; --radius: 0rem; } .dark { --background: 20 14.3% 4.1%; --foreground: 60 9.1% 97.8%; --card: 20 14.3% 4.1%; --card-foreground: 60 9.1% 97.8%; --popover: 20 14.3% 4.1%; --popover-foreground: 60 9.1% 97.8%; --primary: 20.5 90.2% 48.2%; --primary-foreground: 60 9.1% 97.8%; --secondary: 12 6.5% 15.1%; --secondary-foreground: 60 9.1% 97.8%; --muted: 12 6.5% 15.1%; --muted-foreground: 24 5.4% 63.9%; --accent: 12 6.5% 15.1%; --accent-foreground: 60 9.1% 97.8%; --destructive: 0 72.2% 50.6%; --destructive-foreground: 60 9.1% 97.8%; --border: 12 6.5% 15.1%; --input: 12 6.5% 15.1%; --ring: 20.5 90.2% 48.2%; } }
2 replies
TTCTheo's Typesafe Cult
Created by gnarley_farley. on 12/8/2023 in #questions
What's the best way to handle WebSockets and streaming for these AI apps + t3?
How you do this?
5 replies
TTCTheo's Typesafe Cult
Created by gnarley_farley. on 6/6/2023 in #questions
When using Zustand in a mono
How should i set it up , should i have a separate store for every project?
2 replies
TTCTheo's Typesafe Cult
Created by gnarley_farley. on 6/4/2023 in #questions
WHEN to not use SSR?
can someone explain to me when not to use SSR? I never want to see a loading indicator when i open a new page. So i dont really understand when not to use it. In the past i've generally used SSR on all slug pages and not or some index pages that are not important for SEO. But why not just use SSR with revalidation on every single page? The pages load faster and the data is never stale either way so why would i not just use this across the whole applciation?
3 replies
TTCTheo's Typesafe Cult
Created by gnarley_farley. on 6/2/2023 in #questions
Desperate for help with Trpc resolver.
How can i get resolve({ default: base64Data }); to only trigger once trpc has returned success or failure. class MyUploadAdapter { private loader: any; private mutation: any; constructor(loader, mutation) { this.loader = loader; this.mutation = mutation; } private async _uploadFile(file: File) { return new Promise((resolve, reject) => { const reader = new FileReader(); reader.onload = async () => { const base64Data = reader.result?.toString().split(',')[1] || ''; // mutate will automatically handle success and failure. try { await this.mutation.mutate({ base64Data, }); resolve({ default: base64Data }); // Since mutate will handle success and failure, // you don't need to manually check for errors or success here. // Instead, just resolve with the base64Data, // and CKEditor will handle the result. } catch (error) { // The error is caught here but it has already been handled by the onError handler. reject(error); } }; reader.readAsDataURL(file); }); } }
14 replies
TTCTheo's Typesafe Cult
Created by gnarley_farley. on 5/31/2023 in #questions
A question on procedure design.
I would like to know if it is best to try combine procedures or keep them separated. I don't want to repeat myself but am not sure regarding best practices for this types of thing. Would appreciate if someone could push me in the right direction. Something like this for bookmarks on 2 different post types bookmarkPost: protectedProcedure .input( z.object({ postId: z.string(), }) ) .mutation(async ({ ctx: { prisma, session }, input: { postId } }) => { await prisma.bookMark.create({ data: { userId: session.user.id, postId, }, }); }), bookmarkTech: protectedProcedure .input( z.object({ techId: z.string(), }) ) vs. combined bookmarkItem: protectedProcedure .input( z .object({ itemId: z.string(), itemType: z.string().refine(value => ['post', 'tech', 'course'].includes(value), { message: "Item type must be either 'post', 'tech', or 'course'", }), }) ) .mutation(async ({ ctx: { prisma, session }, input: { itemId, itemType } }) => { switch(itemType) { case 'post': await prisma.bookMark.create({ data: { userId: session.user.id, postId: itemId, }, }); break; case 'tech': await prisma.techBookMark.create({ data: { userId: session.user.id, techId: itemId, }, }); break; case 'course': await prisma.courseBookMark.create({ data: { userId: session.user.id, courseId: itemId, }, }); break; default: throw new Error("Invalid item type"); } }),
6 replies
TTCTheo's Typesafe Cult
Created by gnarley_farley. on 5/23/2023 in #questions
What is the easiest way to get your content from the trpcState
2 replies
TTCTheo's Typesafe Cult
Created by gnarley_farley. on 5/22/2023 in #questions
How to solve infinite compiler loop when using withNx and withContentlayer together in next.config
trying to figure out how to configure contentlayer with my t3 app in an nx monorepo. if anyone has some ideas, please hola.
2 replies
TTCTheo's Typesafe Cult
Created by gnarley_farley. on 5/20/2023 in #questions
Having issues with state and TRPC serverside component -> Like button on zustand
I am really struggling to get the correct state when refreshing the page. If i leave the page and navigate back to it, the state is always correct. But if i refresh the page the state is always set to false and not in sync with what's currently in my store. I believe it has something to do with the serverside helpers and the id of my post not being available on the reloads. Has anyone come across this behaviour. it's basically forcing me to do this const { likedPosts, addLikedPost, removeLikedPost } = useLikeStore(); const [isLiked, setIsLiked] = useState(false); useEffect(() => { setIsLiked(likedPosts.includes(id)); }, [id, likedPosts]); which cannot be correct. the likePosts.includeds(id) should be responsible for the state. I should have to use the one state to check the other state.
2 replies
TTCTheo's Typesafe Cult
Created by gnarley_farley. on 5/18/2023 in #questions
What is the best way to push data from external sources into my db?
I want to import data from external sources into my app. I think it would be more efficient to access the database directly. We usually use FastAPI for our Python backends. I am curious if I can use Prisma/trpc on my backend and keep the Prisma schemas in sync somehow. This might be a crazy idea. I would appreciate some advice on this. Basically, we have a NLP department that generates content and needs to push it into the db's of the different apps. Wondering what the best route would be to do so.
3 replies
TTCTheo's Typesafe Cult
Created by gnarley_farley. on 5/17/2023 in #questions
How do i make a trpc call outside of a functional component
How do can i implement a trpc call to upload an image in here instead https://medium.com/swlh/ckeditor5-with-custom-image-uploader-on-react-67b4496cb07d
3 replies
TTCTheo's Typesafe Cult
Created by gnarley_farley. on 5/17/2023 in #questions
Initiating another prisma client for SSR
I closed my project, opened it up again and got an error on prisma.etc. On my page that does SSR. I have since added the prisma client on that page. Initiated it, now it's working. Then i deleted it, shut down my project and spun it up again and it's working fine. What is this magic? /code xport async function getStaticProps( context: GetStaticPropsContext<{ slug: string[] }> ) { // const prisma = new PrismaClient(); const helpers = createServerSideHelpers({ router: appRouter, ctx: { prisma }, transformer: superjson, }); const slug = context.params?.slug; // Access the first element of the slug array await helpers.post.getPost.prefetch({ slug }); return { props: { trpcState: helpers.dehydrate(), slug, }, revalidate: 1, }; } export const getStaticPaths: GetStaticPaths = async () => { const pathsData = []; return { paths: pathsData, fallback: 'blocking', }; };
2 replies
TTCTheo's Typesafe Cult
Created by gnarley_farley. on 5/16/2023 in #questions
Lets Talk about State Management
Hey everyone! I've recently developed my first relatively large application with T3 and started using Zustand for state management. I'm curious to learn about the best practices for state management and when it's appropriate to use local state (e.g., useState) versus Zustand. Up until now, I've been using Zustand to avoid prop drilling and manage state across multiple components, and it's been working great. However, I haven't clearly defined in my mind when to choose between local state and Zustand. Any tips would be greatly appreciated! Also i'm curious as to how updating the state management works with rebuilding and pushing projects. Is it just something that is taken care of in the background? We're launching some community based apps in the near future and I'd like to try avoid as many issues as I can.
4 replies