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

Zod validation for datetime

Hello! I am trying to follow this doc: https://zod.dev/?id=datetime-validation It is giving me an error for whatever reason. Has anyone tried this validation?...

Why won't my React app send HTTP-only cookies in WebSocket upgrade requests in production?

Hi everyone, first post here - I'm currently building a full-stack TypeScript chat app with React + Vite on the frontend and Node on the backend. I have two separate servers running: one is a REST API and OAuth2 auth server built with Express and Passport.js and the other one is a WebSockets server built with the ws package. They run independently (no interprocess communication whatsoever) and use stateless auth in the form of JWTs. Here's how my current flow works: users first log in with either their Google or GitHub account, and once the first server has verified their identity, it sends an HTTP-only cookie down to the client. This cookie is send back to the server on all subsequent requests and I have some middleware that runs on the REST API to parse and verify the JWTs on protected routes. Once it has the cookie, the client then initiates a WS connection with the second server, which also checks for the JWT cookie in the incoming HTTP Upgrade request and verifies its signature before allowing the new client to continue exchanging messages. Both servers and the React frontend app run on different URLs, both on local dev and prod, so all requests are cross-origin, but CORS is enabled on the REST API/auth server and as far as I know the WebSockets protocol doesn't implement any CORS policies......

Multiple DB Connections and Prisma clients

I have 2 databases that are handling different elements of my platform; because of the limitations of Prisma for multi-tenant connection, I need to have multiple clients. At the same time, using the output property does't resolve correctly in my Turborepo setup, so it makes it difficult to do so. I'm getting some conflicts between the clients, and had to ultimately take one of my clients out of the packages, and move it side-by-side with the app that uses it most. It's just inefficient; anyo...

Getting dupilcate data from table pagination

Hi, I am currently working on paginating a table with data from a database using prisma and trpc. But there is one record that keeps being displayed as the last element and I am not sure why it is happening. The record being shown is always at the bottom with the name Jan Bogan which can be seen in the screen shots...

Is it a bad idea to choose to use mongodb with Prisma on the t3 stack?

Basically, there's an already setup mongodb in a project, I could push to use a relational db but for now it will only be used for users so Id probably live with mongo for now. I've read some stuff here that Prisma doesn't work well with mongo, does anyone know its issues ?...

Prisma npx db push on vercel --prod

How do I populate the tables for my production database when I push to vercel the first time? Do I have to do it manually?

Image url from s3 as next page

How can I create a proxy page component so to say to view my files from my s3 bucket inside my webapp, so I don't need to open the files using the s3 url. So I would pass the presigned url from my backend to my component page I guess, which I already created inside ```ts...

Typescript const to functions component type.

How to convert this const to function in typescript const Home: NextPage = () => { return <>...</> } to ...

tRPC and Vercel Serverless Functions?

When using tRPC on Vercel, will all trpc enpoints be serverless functions? Or it will be count like only one serverless function?

which database will you recommend if i was to build a Twitter like app

I love mysql very well and use it always on all projects But for this i think PostgreSQL will be best What do you think?...

Sort imports

So using the create-t3-app im using the https://www.npmjs.com/package/eslint-plugin-simple-import-sort lib to sort my exports because it freaks me out to have these imports unsorted. And i extended my eslint config as follows: ```ts { "parser": "@typescript-eslint/parser",...

TypeError resolver is not a function at apiauthsession endpoint

Im trying to configure Google Credentials with the Google API to have the login working. Ive put the URI redirect to http://localhost:3001/api/auth/callback/google (im using port 3001) On my Signup button i have ...

How to return additional fields from user in session callback next-auth?

Hi all! I have the following schema: ```typescript model User { id String @id @default(cuid())...

How do I pass a custom error from my backend to frontend?

How do I pass a custom error from my backend to frontend?

T3 Stack Access Env Variables Without Prefix On Frontend

How do I access an env variable without the prefix on the frontend? I want to be able to use the same env variables across projects (Deploying on railway using environments) so how would I access the env variables on the frontend without the prefix

refresh token

How do I implement automatic refresh in t3? I found this link: https://github.com/TanStack/query/discussions/2770 but using trpc there's no where to specify "await refreshAuthToken()". Can't do it in "retry" either because it cannot be made async. Any help is greatly appreciated!

Using getServerSideProps vs TRPC in T3Stack

Hey quick thing, should I use getServerSideProps use or trpc.auth.getSession to check for auth when loading pages ?

How much cost Railway?

Can someone who has had experience with Railway.app give me an estimate of how much it costs? I'm looking now for the Developer Plan.

.default('') on Zod doing nothing

I have a validator for the profilePictureUrl that sets the default to an empty string.. or so I thought. I'm getting errors like:

typescript props as object or array

Hey guys, I have a select that can or not be a multi-select So my select props are ```ts type SelectProps = {...