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

Stripe - Payment Intent

Hello, I am trying to use payment intent which return a client secret. How can I get the checkout URL. When I went through their process they are suggesting to get like stripe elements to create form on front end and stuff. but is there a way if I could just return the checkout url form the backend?...

Learning a functional lang

Has anyone got recommendations on a functional programming lang to learn? Kinda wanna get into it lmao

Type that omits all inherited properties?

Say we have ```ts class Person { age: number } class Child extends Person {...

Loading UI not interactive

Hey, I played around a bit with loading ui's in next 13 and for some reason links, buttons, etc. can't be clicked during loading. I wondered if that is correct or if im just stupid Thanks...

Question about Prisma Data Proxy on Vercel

So I just setup Prisma Data Proxy with my Next project deployed in Vercel, but I noticed something weird is happening with the schema it seems like its not being updated in production even tho its updated in my main branch in Planetscale.. Is the migration setup required to deploy on vercel using data proxy? I think thats what im missing but not sure...

Getting weird error on Vercel when deploying app

So my app works fine locally, however, I pushed to vercel and everything is fun except the fact my TRPC Returns this error: ```"TRPCClientError: Unexpected token 'A', "An error o"... is not valid JSON at u.from (https://myapp.vercel.app/_next/static/chunks/pages/_app-e0b32bccfebdf428.js:1:20800) at https://myapp.vercel.app/_next/static/chunks/pages/_app-e0b32bccfebdf428.js:1:24691"...

Prisma and Stripe subscription authorisation

I am working on a side project that has different tiers of subscriptions. I'm using Stripe and have set up everything to sync up subscriptions, prices and products from Stripe with my database. Now depending on the tier of the subscription users have certain restrictions. For example (completely random), imagine restricting people to X blog posts, Y tweets per day or access to feature Z . Would you guys put this information on the metadata of the Stripe product like
{"blogLimit": 5, "tweetDailyLimit": 10, "featureYEnabled": true}
{"blogLimit": 5, "tweetDailyLimit": 10, "featureYEnabled": true}
...

Purpose of auth.ts file

Is it just there to showcase the use of protectedProcedure or what should generally go in there? Let's say I have a recipe app and I want only logged in users to be able to create a recipe. I suppose I'd have to use the protectedProcedure in a file like "recipe.ts" and not "auth.ts" to do that, right? Thank you!...

tRPC React - why the useState hook?

Hey. I've been following the docs for setting up tRPC for a React based project. I noted in the docs that they recommend wrapping the tRPC client into a useState(). Could someone explain why?

useEffect infinite loop

I am inserting values into my db using useEffect but it causes infinite loop

TRPC Invalid type error

Im trying to call my trpc endpoint from my chrome extension and im getting confused over the format i need to call it. What is the correct way to call a trpc endpoint when not in the next environment.

Zod one or more values from an array

Thanks in advance, my mind has gone blank and I just cannot think at this point. How can I say with zod I want to have at least one value of these array of possible values passed through. So basically a multi select picklist....

React-Native Error Cannot handle 'public.jpeg' media type

When I set allowsMultipleSelection true I get this error but not when setting it to false?! Why is that and how can I fix this?

BasePath and Locale broken

Adding basePath and redirect to it seems to break the app. Every time I enter my root page / it redirects me to /en/basepath (404) instead of /basePath. Whats wrong with this config? ```js { reactStrictMode: true,...

Auth on Mobile vs Web

In my mind, auth is mostly collecting username/password and sending it to the server, then the server can verify whether or not the username/password is correct. When the user visits again, I guess we need to re-authenticate with the JWT that's on the device. But none of these seem to mean that we need to do anything different for mobile vs web yet things like NextAuth don't support mobile yet, and most auth solutions have separate SDKs for mobile/web....

tRPC + external API

Hello. This might sound dumb but currently we need to expand the usability of our backend for a specific project. We will need to create a Typescript backend and I was thinking of using Next + tRPC. Question is, I will also need to interact with said backend on some cases but through tRPC endpoints in my app. Does doing this makes sense? And in that case, how can I make a tRPC procedure depend on a regular http call? Like for example formating some data and send it awaiting response from that POST call to our backend....

Apollo with nextjs 13 ?

Hi i'm a bit of a newbie, I want to build a blog app using next js 13 and the CMS strapi. I cant understand what is the best approch to make querys with this new server component, should I use the new fetch() function from nextjs server component or make querys with apollo on client side ?...

Use Prisma Enums in Runtime Validator

Can I use Prisma's generated enums in a zod runtime validator? I have in the @prisma/client this: ```ts export const Language: {...

NextAuth Discord Getting Guilds

I've been trying to do this for hours now, how do I fetch the users guilds via NextAuth ? I then want to store the guilds within the guilds within the token. Spoon Feeding would be amazing, I have depression because of this.