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

Scalar lists but on Planetscale?

After starting to watch the tutorial posted day, I bit the bullet and am going to give planetscale a try! I use 2 scalar lists in my current setup to store an array of tags for posts. These don't work on planetscale. Database experts (or simply not a noob like me!) What is the best alternative to use?...

Handling OAuth Login Errors with Dynamically Generated URLs in Vercel Deployments

I'm encountering an error when trying to log in with OAuth on my website. The error message indicates the specific URL I need to add to the redirect list. However, this URL is dynamically generated as a website preview by Vercel. Is there a method to ensure that this, as well as future deployments and branches with different URLs, will work automatically? Wildcard will not work:...

Prisma p.account.create() error "Column: for"

When I sign in with discord, it works fine, when I sign in with spotify, I get this error: "The provided value for the column is too long for the column's type. Column: for" I dont have a column "for" in my schema. Prisma creates a new user table, but cant create an account for the user. ...

tRPC Error handling

im trying to understand how tRPC handle 400 errors request what i got so far is im doing this in my procedure
if (exam) throw new TRPCError({ code: "BAD_REQUEST" });
if (exam) throw new TRPCError({ code: "BAD_REQUEST" });
...

❌ tRPC failed on partition.getAll: UNAUTHORIZED

Hello gentle-men/waman, i have been struggling with implementing a custom credential provider the last two days.. haven't slept properly.. and now i must admit i need assistance. I have successfully implemented the "login/nextauth" part of the job, in the client side.. but when i call my queries from client i get ❌ tRPC failed on partition.getAll: UNAUTHORIZED .. I think the solution is that i somehow get my session from useSession() send to TRCP or auth by TRCP, but i dont know... thats what been bugging me the last 48 hours.. please some kind soul.. HELP MEE 🤯 P.S it think has something to do with the way the protected procedure autheticates a user. P.P.S if you need any futher information. Please dont hesitate to ask me. Thanks in advance!!...

Airtable OAUTH using NextAuth

been stuck for this for last 5 hours pain i want to use airtable through oauth in my app and fetch data this is the link to airtable oauth docs: https://airtable.com/developers/web/guides/oauth-integrations ...

Astro Zod environment variable validation

How can I implement the same pattern T3 app uses in env.mjs uses in Astro?

create csv on the backend and server for download

I have a table called pollResults. It contains data that my users want to download into a csv file. What is the best way to generate that file on the backend (using t3 stack) and then serve it as a download on the client? ideally without getting anything like S3 involved.

is it "ideal" to directly fetch /api/trpc/route.procedure in another server

im wanting to use my create-t3-app app as main source of data for a different server, and for this i need to access data from the trpc server on the the other server, is it a good idea to just fetch (for example) http://localhost:3000/api/trpc/route.exampleProcedure in this other server the procedure is public anyway so handling request authentication doesnt need to be done...

how to store actually boolean in mysql instead 0 and 1

Please, is there any way to enforce Boolean to be stored as true and false, not 0 and 1 in mysql I am uisng prisma × mysql...

Any good practices for creating trpc queries/mutes that don't use Prisma, in a t3 app that does.

From my understanding adding Prisma to the context of a router at it's base (createTRPCContext), results in the Prisma client being present in all sub routes used by that router, but we don't always need access to it so it's slowing down some serverless functions unnecessarily. Currently trying:
Separate Routers : Creating separate tRPC routers with different contexts (one including the Prisma client)....

Type for request and response. Should they be shared?

Let's say I have 2 apis - getTask and createTask For createTask I need the request to be of the type - ``` {...

How do you initialize/seed your DB with/for static values? (e.g. post categories)

Imagine you'd need to put some static values in the DB, for example post categories. Each category gets a unique ID (string). These categories are not changed by any user, only be me, as the admin. Where and when would you put these static values into the database? I thought about three variants to create these post categories:...

Is there a way to make Typescript smarter when implementing a class?

```typescript class AbstractClass { testMethod: (a: string, b: number) => Promise<boolean> testMethodTwo: (a: string, b: number) => Promise<boolean> }...

create-t3-app Dockerizing base install fails with Prisma?

I am trying to learn and understand how to do things with Docker, and I saw a Deployment part of the Website which seemed great, but i seem to get stuck on the DATABASE_URL env variable. I was trying to set up a docker-compose for it, but by default it isnt showing how to stand up a separate prisma setup server of sorts. I want to flush out this a bit more, since prisma can make a postgres or various other setups, but i didnt see much regarding it when looking at how to take this base app and create the appropriate containers for it. Can someone point me in some direction on how to get this aspect working? Seems like I will need it to generate a db container, or some other mechanism. to see how I can build the rest of this aspect....

How to store session in DB using credentials provider?

How to store session in DB using credentials provider? Otherwise, I cannot manage the user's logout from the server side.

mutate return value

So I am not getting all of the data on my mutate return. I am creating a task, which has subtasks (relational to the task) and I am creating them while creating the task all in one big block, the thing is that the return value when calling this createTask function doesnt give me the subtasks too, only the task that it created, how can I achieve the behavior I am seeking?...

Display modal on back button click

Hey all, I've received a task wherein we're displaying a modal on an order form when the user takes certain actions that will trigger a modal offering a discount or some other product depending on a vendor's settings. One of the requests is to trigger the modal when the user clicks the back button. Essentially, the user clicks back, the modal pops up saying "before you go, here's the offer", and then never triggers again. As annoying as it is, I figure I should look into how this could be done. My idea was to pushState under certain circumstances a dummy entry, so that when the user clicks back to leave the SPA, there's that buffer for us to detect popstate, show the modal, and then flip a boolean that will fix things up to allow back navigation afterward. However, it seems browsers have begun trying to skip duplicate entries when back is clicked, seeing discussions such as https://github.com/WICG/interventions/issues/21 and https://github.com/whatwg/html/issues/7832. I've thought about potentially doing some kind of client-side routing (we use React Router), and a <Prompt /> that'll get me there, but that seems like a bad idea both because it's hacky and because I don't believe navigation blocking are available in the same way in the newest version of RR....

The inferred type cannot be named without a reference?

I am genuinely clueless on how to solve this error
The inferred type of 'init' cannot be named without a reference to '.pnpm/@sentry+core@6.19.7/node_modules/@sentry/core/types/integrations'. This is likely not portable. A type annotation is necessary.
The inferred type of 'init' cannot be named without a reference to '.pnpm/@sentry+core@6.19.7/node_modules/@sentry/core/types/integrations'. This is likely not portable. A type annotation is necessary.
...