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

Changes to schema.prisma

Whenever I want to push changes to a model in my schema.prisma, it asks me to delete all the available data first. Is there a way to get around this? What is the standard way of pushing up changes I make to my db?

Creating an npm command

This is a bit left field but I know the creators of ct3a are here and I wanted to know how you went about creating the npx create-t3-app command . I plan on doing something like this for Electron apps . I want to be able to scaffold a new project with my favorite packages for building desktop apps without having to do the setup every single time. Thanks in advance for the replies...

How to use arguments property from function in TS

Is it possible to use arguments from Function in TS or i have to use rest operator? Because when im trying to do this, im getting error:Expected 0 arguments, but got 4.ts(2554) JS Example ```js...

3rd party Zod validation

Has anyone ever validated 3rd party requests with Zod? Running into an issue where one property might be different down the line since we don't control this api. If I use safeParse it'll give me an error object but no validated data. Is there a way to retrieve the validated data sans the property that errored out? Maybe I'm overthinking this?...
Solution:
you can also do like ```ts const parse = someSchema.safeParse(apiResponse); if (!parse.success) {...

How to model my Prisma for a Golf-application

I have this golf application where all Users have their own bags. Inside their bags they have several Golf clubs. I want to fetch their bags and also list out all the golf clubs inside their respective bags. ```...

next-auth with custom backend

Hello, does anyone have experience with next-auth? I'm struggling to understand how to make my use case work. I basically require to authenticate using an OTP sent to a phone number; this part is taken care of using CredentialsProvider. I basically have a custom backend that sends me the JWT token and user info after a successful login, but after that, I'd like to use this JWT in a cookie to authenticate my future requests. I noticed that next-auth creates its own JWT after signIn() is called but I'd just like to use mine instead, is that possible? this is my current [...nextauth].ts options: ...

Nested keyof

Hi all, I am trying to use a fancy type to get a nested keyof effect. I found this code snippet online: ``` type NestedKeyOf<ObjectType extends object> = {...

Type Error When Using Nextra With Turborepo

Hello! I am running into the following type error when running a dev server for my docs powered by Nextra in a turborepo. The error is: TypeError: Cannot read properties of undefined (reading 'Compilation')...

Simplify Renaming a Field in Prisma Schema with PlanetScale

I'm looking to rename a field in my Prisma schema while using PlanetScale. For instance, I'd like to change authorId to userId. I'd like to achieve this without losing any existing data in the field. Normally, creating a custom Prisma migration file would be the way to go, but due to the incompatibility between Prisma Migrate and PlanetScale, it appears there isn't a straightforward approach. Is there an easier solution that preserves data and works seamlessly with PlanetScale?

vitest error

I was writing some tests yesterday using vitest which I have had set up for a long time. Everything was working fine and then all of a sudden I started getting this error from the framework (see image). I can't find anything about this error online and I didnt change my vitest config at all. Anyone have any ideas what's going on? ```ts // vite.config.ts...

Is Prisma DataProxy production ready?

In Theo's latest video he mentions that Prisma is working on making it work with the Edge, but I've found in their website a working example and tutorial... Is it not good enough yet or what is the problem here? (didn't try it myself yet) https://www.prisma.io/docs/data-platform/data-proxy/use-data-proxy...

Global state management in T3.

Hi, this is probably a nooby question but would recommend me to use zustand in this case?: I have a cart which lives on the Navbar. Item Page has a „add to cart” button. I want to open the cart after clicking this button. This is a cart that lives in the database so I could maybe try open it onSuccess as it will be refetched after clicking the button, but it would also mean the cart would be open on initial render of the site :/ ...

"trpc failed on posts.getAll" - unsure what is broken and how to debug it?

I've gone through almost all of Theo's Chirp tutorial. I originally had the same middleware issue as other folks and used the matcher config code that was posted to solve that problem. I've been continuously testing my build throughout the tutorial. It was working perfectly when I finished the "profile feed" part - I committed and deployed to Vercel, and then it just stopped working and I get the "trpc failed on posts.getAll - Author not found" error. I even reverted my previous commits and the...

tRPC, Prisma, Discord Bot and tracking mass messages

Currently rebuilding building an app which is using NextJS (on Vercel), tRPC, Prisma, PlanetScale with a Discord bot all housed in a nice little Turborepo. Now, you can create posts from the web app that get posted to fairly large number of Discord Servers (~700, and growing). When the post gets approved by an admin (in the web app), it updates the post to approved through tRPC, tRPC calls the Discord bots little Express API to tell it to get the approved post and start sending the messages. ...

How to redirect using trpc nextjs base on db query?

This seems less intuitive than it should've. I'm trying to check if a user is new, if it is then I redirect them to a new page to setup their profile. So far I've tried to do it with react, trpc, middleware, it doesn't seem to work. the problem with react is I can't get the current session using clerk with useAuth, and I'd like to redirect before the page starts rendering,....

Best way to fetch external api with variable & env_variable body data?

Hiya, I'm struggling on this and would love some help from one of my favorite communities ❤️ So I have a contact form that upon submission should send a fetch to an external api with the form data and an api_key that I currently have stored in an env variable. Currently I have tried different routes using useQuery, fetch, axios, & trpc....

Order of request hitting

What is the order of files/functions getting hit by an incoming request? Of getServerSideProps, _app.tsx, _document.tsx, and the content of a page (index.tsx)?

Tailwind seemingly not working randomly when deployed.

For some reason, when I deploy to vercel, some of my tailwind is simply not applying. For example below screenshot, you can see that I have set property w-56 which isn't being applied when deployed to vercel, however, in development it looks fine. Same applies for the hover text....

nextjs 12 (and below) same getServerSideProps function in multiple routes

is there a way to call the exact same getServerSideProps function in multiple (nested) routes? I want to check if the current route/page matches some path regex, and if it does, call the getServerSideProps function. Else, do nothing....