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

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

how to delete a child object in prisma

how do i remove one follower from the followers array ``` model User { id String @id @unique @default(cuid()) handle String @unique @default(cuid())...

How to return multiple prisma calls with trpc

how do i return two prisma calls ``` follow: protectedProcedure.input(z.object({ userid: z.string(), pageid: z.string() })).mutation(async ({ input, ctx }) => { ctx.prisma.user.update({ where: {...

Proxy prisma calls to FE with tRPC

Hi there. First of all, I'd like to thank everyone involved in the T3 project. It is really awesome. I have a question. Is there a way to just proxy prisma calls to FE with tRPC? So that we don't have to create procedures, duplicate inputs... Just something like: ``` export const appRouter = router({...

Prisma allowing empty DB fields

Hey guys. Day one of using Prisma, so probably something simple Im missing or not understanding. From reading docs, if no type modifer is provided, the default behaviour is fields are not null. That being said, it is letting me submit records without certain fields missing. I have created records through both my TRPC endpoint, and Prisma Studio, and in both I can omit a field and it doesn't reject it. Attached a screenshot of my model and an example record. Any ideas?

NextAuth-Try signing in with a different account

When I log in with my account everything works fine. But when anyone else tries to login they get this message: "Try signing in with a different account" I see there is an open issue exactly on this: https://github.com/nextauthjs/next-auth/issues/3830 Just curious if anyone is aware of an easy fix for t3 stack? Thanks...

media files do not show on my netlify site when I deploy my astro project.

I have this astro project working just fine on my local machine. when I do build and preview everything works as expected. but when I deployed it on netlify all media files and favicon stopped working. I have some fonts in the src directory and they work fine. but the media files in public directory do not show up. ...

Confused on types of prisma responses, and how to access the data inside.

The NextAuth 'Account' model in prisma has a 'access_token' property that I need to access for a API call on the server. However, the only property I can access in the trpc context is the "session" model. So, what I am doing is querying users for the user that has the session from the context, then getting the account array from that user and getting the account from there. (1st image) ...

Do Planet Scales 'Dump' & 'Restore-Dump' via the CLI restore data + schemas or JUST the schemas?

Maybe a silly question: If I do a pscale database dump [database] [branch], will this save and backup the data, and then I can restore the database including all schemas + saved data via restore-dump <DATABASE_NAME> <BRANCH_NAME> ? Or will it just restore the schemas? ...just asking to make extra sure, I'm a little scared 😅...