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

Prisma - differences between id, unique, and index

Hey 👋, Could someone explain the difference between @id, @unique, and @index?...

image validation using zod

i wrote this in the tRPC router but it gave this error ``` createComic: protectedProcedure .input( z.object({...

Help with some type declaration

I'm using create-t3-turbo and in expo/src/screens/home.tsx, PostCard component's prop type declaration is as follows: post: inferProcedureOutput<AppRouter["post"]["all"]>[number]; What I don't understand is what the [number] at the end means....

Does any one know how to await trpc queries?

I want to fetch data in getServerSideProps using trpc. Can you await results?

Strategy to test components in React

Hey, I am new into testing and I haven't test anything much before. I am still getting stuck about theory what should I test and what shouldn't. For example here. I have component Heading that takes prop level which is number between 1 and 6. Is this test useless? And if so, what test would you write for this specific component?...

Prisma suddenly stopped working in docker deployments

My docker deployments of T3 apps just broke. They all use the up-to-date Dockerfile from the T3 docks. Strangely, it seems to me like even those that i haven't rebuilt in a long time broke. So the problem might be somewhere in my system maybe? (my host is Ubuntu 22.04). Here's the error i get when any prisma call happens in my app: ``` Unable to load Node-API Library from /app/node_modules/.prisma/client/libquery_engine-linux-musl.so.node, Library may be corrupt...

Has anyone found an easy way to implement HeadlessUI and RHF?

All I find are examples with tons of boilerplate and it feels like it shouldn't be as hard to create a form with a custom component made using HeadlessUI or any other headless ui lib.

Prisma Disconnect Where

Hello, Does someone know how I can disconnect a relation between 2 models based on the id's in an array? I.e....

input type file is cleaned upon tab change

I'm using "react-tabs", where each tab renders a different form. Some sort of a multi-form. I have an input of type file in my 1st tab. A problem occurs when I use it to upload an image, and switch to a different tab. When you go back to the original tab, the input is empty. I saw a suggestion online to just hide the tab when its not active, but I can't since I'm using a library. ...

Environment Variable Error when using prisma client directly in getStaticProps?

Normally using trpc, but just tried to make a prisma call in getStaticProps directly: ``` let data = await prisma.item.findUnique({ where: {...

How to handle Failing Unique Constraints?

I am wondering how to handle those on a practical level. I have a frontend, where I can import lists of items into my database (prisma + mysql on planetscale). Right now, when a unique constraint fails, the whole import will fail. 1) Is there a way for me to tell my frontend, what item on the list failed the unique constraint? Right now I get: ```...

Old codebase, outdated tool chain - how to limit the blast?

I have a 5-6 year-old enterprisey React codebase at work with a bunch of dependencies that for the most part haven't been upgraded since the day they were first installed. Most of the build chain is two+ major versions behind current: webpack 3, babel (& all loaders/plugins) v6, from before the monorepo reorg, Jest v23, and Flow 🤦 version 0.37. For those who haven't been keeping up with Flow (and who has?) the current version is 0.195.0. It's so old that the flow-language-server in vs code won't start, and the Stripe flow-to-typescipt-codemod works only partially and leaves several thousand compiler errors that it can't address. Oh, and it's also an ejected create-react-app codebase with a lot of custom build scripts and a really bespoke end-to-end testing setup that I don't pretend to understand. Anyone who understood this codebase has long since moved on. Right now I'm as expert as anyone else here, and I have the team's blessing to take the reins and upgrade this all to a modern stack. But as I experiment with it, it's a pile of pickup sticks, because anything I pull on seems to require me to upgrade everything else. Target state is Typescript replacing Flow, and either Vite and Vitest replacing the rest of the toolchain— or if that's impossible, at least modern versions of Webpack and Jest....

Can't figure out how to disconnect in prisma

I've been trying to figure out how to disconnect feed from user for like 2 hours now, and I can't figure out what part I'm getting wrong, my function looks like this: ```Typescript removeUserFromFeed: protectedProcedure .input(z.object({ feedId: z.string() })) .query(async ({ ctx, input }) => {...

T3 NextAuth - Email Provider WITH Username

I've gone through a few T3 tutorials and I'm creating my own application now. Does anyone know the correct way to add a username to the initial user-signup via the NextAuth email provider? Yes, I could have the user specify their username AFTER they click the link in their inbox, but it would be nice if they specified it when they type in their email during signup. I could create a route for a username mutation but the user technically doesn't exist in the database until AFTER they click the link in their inbox....

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...

Prevent trpc refetching

Does anyone have an idea how I prevent trpc refetching, current I have following queries in a page: ```ts const Game = () => { const { data: movies } = trpc.movie.getAll.useQuery();...

Using multiple git accounts in VsCode

I want to use different git account for my two projects in same device. Is it possible to do so . Without deleting git config again and again. Sorry if that's too dumb question...

Unstyled component library recommendation

Yes. I've already gone through recommendations by t3 docs. All of the 3 libraries look amazing. But like if you were to build design system for your project what would you pick? HeadlessUI is what i was leaning towards more because it's by tailwind team itself. But it has very few components and that doesn't seem like right choice. Suggestions?...

Zod form email required

I have a simple form, for my email auth using next-auth, right now if I enter my email and submit the form I get this error in my browser's console log: ```ts {email: {…}} email...

Next Image and Caching. High RAM usage.

Hi, recently i've been looking more closely at my RAM usage on my nextjs droplet. And i've noticed that the RAM on a fresh instance of the app sits at around 150mb (on the node process), but after some time and clicking around on the website it starts racking up to as much as 1.4GB/1.5GB I have available - this dramatically slows down everything. I turned image optimization off, and it never got higher than 300mb with it off. Is this normal? Am I doing something wrong?...