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

.mutate() underlying implementation

Can .mutate() substitute a fetch('POST') I switched fetch() to .mutate and everything is working out. I just don't understand what mutate does under the hood, I don't want there to be side effects, I just want to do a POST request ONCE and get a response, that's it....

Mutations run in an weird order

So basically I want to create a room using a question and name a user inputs, which would be the input and name state variables. The room is created every time, which is what I want since I need the room id to add the user. The issue is that when the user submits the create a room form, the member is not created nor are they added to the room initially. However, when the user resubmits the form with the same data, a new room is created and the new member is created in the database. I want the member and room to be created on the first submit of the form, but can't seem to figure out why it isn't working. Any help would be appreciated. Here is the snippet of code: ...

Error handling deeply nested writes

This post https://github.com/prisma/prisma/issues/8776 goes into pretty good detail about the issue. I'm just wondering if anyone here has a good solution for this? I have a large form to submit and on submission I have a lot of related data that gets created all at once in my database. I can't have it return an error saying unknown arg. I can't do form validation with a useless error like that. My current thought is to maybe create the new item and then update each of the related fields in separate calls to potentially get an error from each of those. Something like: ```ts #This does not work await prisma.user.create({ data: { ....,...

multiple query in trpc endpoint

hello guys, i got a question is it possible to perform multiple query in single trpc endpoint, im still new to t3 so i cant find a solution to this example: 1. create data in table A 2. and then update a value in table B...

Best practices - defining types when lib doesn't export the type

I'm writing a hook that wraps a transaction from another library. The library returns a Promise<SendTransactionResult>, but SendTransactoinResult is not exported from the library. I'm writing a handler for the promise but I'm struggling with what the best practice would be for defining the type that this callback should expect. ``` /...inside hook.../...

SQL Syntax error

Getting this error
[ { message: 'syntax error at or near "SELECT"' } ],
[ { message: 'syntax error at or near "SELECT"' } ],
Here:...

zod foreign key validation

This is probably a question that has been answered to death but I can't find anything that really helps so apologies if that's the case I'm trying to validate a create mutation for a album table and I want to have a field that specifies the episode id foreign key that the album is discussed in Getting the error 'Type 'string' has no properties in common with type 'MainEpisodeCreateNestedOneWithoutAlbumsInput'.'...

NextAuth middleware

I don't know why when I'm using NextAuth middleware and I successfully log In (I can see session when I disable middleware and use useSession hook on index page) it still redirects me to login page 😕

html `img` tag considered as not same origin?

I have this API that is 100% allowing the client to access it, and now I'm trying make it serve images to the client. so I setup everything and now I can visit the route (dedicated to static files serving) and browse to any file and get that file to show/download in my browser. the only problem is when I use the src attribute of an html img tag, I see this error in the browser: net::ERR_BLOCKED_BY_RESPONSE.NotSameOrigin 200...

useGesture drag and drop scroll behavior

After watching one of Theo's videos I've descided to try to reimplement drag and drop (which was previously using react-beautiful-dnd) to useGesture. i got everything working great but the last thing i need is for the UI to cooperate with scroll. Right now i have 2 problems that i dont really know how to solve. 1. When im holding a card and scroll with the mouse wheel the cursor position desyncs from the card's position. 2. I want the list to scroll when im holding a card and am hovering over the bottom / top of the list. i had an idea to do this by adding a transparent div that would trigger scrolling when i am holding a card and on top of that div. However, i don't seem to get any mouse events while dragging and even if I did I don't really know how to control the rate of scroll in a clean way....

Stripe API and Payment Intents

Hi everyone, I need some help with Payment Intents: My problem is that whenever someone tries to check out, a new payment intent is created. Then if you refresh that page, another payment intent is created. Or if you just go back by accident and click to checkout again, a new payment intent is created. My questions is, what do you do about all those payment intents. According to the docs, you can't really do much about them and they will be stuck in an obsolete state....

vscode extension for showing context

is there a vscode extension that pins the current context (function etc) at the top of the screen like this vim screenshot?

how can i best mimic twitter kind of feed with trpc

talking about randomising post based on interest saw Elon Musk talking about AI mixing any ideas?

exposing supabase url

why this is happening im already add new variable in schema.mjs? any specific reason?

Next.js Limitations

Ok so I'm considering next.js for my next project for that juicy SEO and page load time. I'm concerned I might want to do something I normally do in react and next.js won't be capable and I'll have to scrap it and rebuild with a normal stack. My question is, can you do everything in nextjs that you can do in react? Or since it's rendered on the server, once it goes to the client it no longer behaves like a react app (re rendering with state change)?...

Want to build SaaS course builder app T3 stack or Astro with islands ?

I want to build a SaaS mainly focused around course creation, like teach:able but with way better UX, I need SEO for the actual course viewing part, but for the creation part I want a really smooth UX so everything will be CSR, enough said i think you understand what i'm trying to do, the question is : i'm stuck going with T3 stack, or Astro + Islands components for the dashboard and CSR part of the course creator ?

React native do's and don'ts.

I'm thinking about starting a project in react native with the following tech: - typescript - NativeWind (rep of tailwind) Can anyone guide me as to how i can go about developing this in a proper manner?...

how can i make the query more proffesional

so basically i am tying to get all posts with a particular type of post but same route also serve as the route for search so this complicated things i want to be able to all the post with the particular post type provided and still use same route to filter the post...

Why is my rails app faster than t3?

for serving up some basic json it seems to be at least double in speed there are large differences in infra, im more just curious which parts specifically make t3 app slower for a basic json endpoint basically using the same DB instance i retrieve a user info endpoint...

How to create static pages using T3 stack?

Title, for now I need to create only SOME static pages, but I have no idea how to set them up with next, what I need to add to make them static? Thanks!