Theo's Typesafe Cult

TTC

Theo's Typesafe Cult

Join the community to ask questions about Theo's Typesafe Cult and get answers from other members.

Join

Multiple Clerk apps on subdomains?

Hey, all! Right now, I have one Clerk app that has the production environment pointing to app1.example.com and everything's great. However, when I create a second Clerk app and try to point that app's production environment to app2.example.com, I get "root domain is already in use by another application". Does this mean there's no way to use two Clerk apps on the same domain? If so, anybody know of any good workarounds?...

TRPC error handling

Hey guys. I'm currently looking for some advice in regards to handling errors on my trpc endpoints. My current implementation is as follows: ```tsx const TicketOverview = () => {...

C first or C++

I'm currently learning Rust and its the first low level lang im learning im familiar with programming and im thinking to go further to c or c++ but im not sure which one should i start with nd maybe i'll drop the other one if it serves my needs. I still don't knw that much in DSA and low level stuff. So idk if should i start with c or c++ first after getting done with Rust

Implementing get Request with Prisma

I impleented login route using prisma and also Redis is being used for session management but when a user is logged in another device and the other user opens the website in another device without logging in the returned user is the one who was authenticated from the other device, How can i fix this below is the source codes ```ts import { NextResponse,type NextRequest } from "next/server"; import prisma from "@/prisma/client"; import {Redis} from "@upstash/redis"...

Context on middleware always undefined

I'm trying to use trpc with next-auth using the GoogleProvider. I can sign in just fine, publicProcedures work, but all protectedProcedures will throw UNAUTHORIZED, even though when using the useSession hook on the same component, it returns the correct data. I can also see the session on prisma studio. ```ts...

RSC: Shared layout in different paths

Using Next 13 how would someone share the same layout for two pages that are not in the same directory? In this example I want pageOne and pageTwo to have the same layout but I also want login to not have it so I cannot use the layout 1 level higher. I tried re-exporting the layout of pageOne form pageTwo's layout.tsxand it works but it feels a bit weird
No description

useQuery runs on CSR?!

Hi! When I try to build my next app, the useQuery hooks from my pages are triggered and fail with TRPCError (because you have to be authenticated). I am using ssr: false and my pages don't use getStaticProps or getServerSideProps...

VSCode TS Server and typescript compiler giving different results with prisma

I have prisma setup on a rather large project which has been compiling fine until today. Looking over the commit logs there has been no changes in our prisma files, setup or the code which is erroring. In VS code it is managing to find the types for our models and their respective query types (find many, delete)...

throwing custom errors from trpc mutations

any idea why trpc is ignoring the catch expression? it just throws its own error about unique constraint violation, i want to throw this custom error when there's a unique constraint violation in prisma but trpc is ignoring my catch expression completely...
No description

Autocomplete config for GIT ohmyzsh location on MacOS

Does anyone know where to find the ohmyzsh git autocomplete files now? It seems like they are no longer at $(brew --prefix0/etc/bash-completion.d/ or at their previous usr or etc locations. I'm trying to modify my autocomplete to only show local branches (My project has horrible long branch name prefixes, and I need a way to not use checkout manually)...

Background image on tailwindcss not working.

So when I try to use a background image on tailwindcss/react it does not show up. Been trying to debug for hours. I am not sure what it is. I referred to this documentation when developing this: https://v2.tailwindcss.com/docs/background-image#customizing Any help is appreciated!...
No description

uploadthing/react not showing up or smth

getting this. i have uploadthing installed
Solution:
You can check that in package.json if the dependency is present there try npm install @types/react

Does anyone know how Vercel manages cache eviction?

I have a use case where I really want actual TTL behavior with Vercel cache. I want to specify a period of time, after which NEW DATA are fetched, as opposed to just displaying stale, cached data, while background revalidation happens. The details are below, though they're not terribly relevant to the question. https://twitter.com/AdamRackis/status/1680232416760287233 The workaround I think would work would be to somehow store some sort of timestamp cookie, and incorporate that into my cache key. So my cache key would be something like ...

shadcn Form

Hello im having two forms made with shadcn components and react-hook-from Controller for validation The idea is when u fill the first form and submit it. The second form takes the first one place. I added a cancel button to take the user back to the the first one . I want it with all the fields filled up with the previous data but idk how to do it through the controller....

should i use a pool or connection in mysql

This is my first time going raw on sql. i usually use an orm(prisma) So, in this application; it's an express application I am using
mysql2
mysql2
package to do my queries ...

broken dinamic page react quey

any idea why this doesn't work in a client component? ```tsx "use client"; import { formatPrice, toTitleCase } from "@/lib/utils"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion";...
No description

Batching pros and cons

httpBatchLink and httpLink is different in term of performance or is the same Thanks!...

Zod overrides react-hook-form validation

I have the following form scheme. When I specify rules={{required: true}} on the field it doesn't work because of zod validation scheme. ```ts const trendyolFormScheme = z.object({ brand: z.string().optional(), attributes: z.array(...
Solution:
And as you mentioned you can make it required based on api response, you can use a discriminated union to make things required depending on some data from the api https://zod.dev/?id=discriminated-unions

React query Refetching on page change

let { data: orders, isLoading, isFetching, isError, error, refetch } = trpc.order.getallcart.useQuery(undefined, { retry: 1 });
let { data: orders, isLoading, isFetching, isError, error, refetch } = trpc.order.getallcart.useQuery(undefined, { retry: 1 });
I am using this code ( react query + trpc) , i want whenever i change links , router , the query should rerun and new data should come from the database but it is not happening , i tried various refetching methods but none of them worked , anyone who can suggest something...

expo hermes flags

I want to launch hermes with -Xmicrotask-queue to enable weakref support, but I couldn't find anything in the docs