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

Setting up token auth to a redis cache

Has anyone tried doing this? I'd love to just throw money at the issue but I havent been able to find anything that does what I want. Basically I want to use token based auth with connection limits to connect to the redis server but uhhh I've never done this before. The image shows what flow I'd like to mirror...

What does nextjs do after router changes?

I saw the theo's last video about under the hood of nextjs. Realizing after the first html loaded and hydration is done, then everything is like SPA. This is so clear before I change the route. In my case, I use a state call isDesktop to render mobile/desktop version of a page which depends on media query(default is false when runs on node) ...

T3 Stack Form Validation

In general, I think I can safely say that good form validation requires both: - the client UI to tell the user when form fields are valid - the server checks all of the fields and validates them before accepting a request ...

How do I detect mock GPS location?

I want to detect mock/fake GPS location using React Native (Or any language/whatever for that matter). If any of you people have done anything similar or have an idea on how it's done, let me know! Couldn't find much by searching. May not exactly be the server for this, but this is the only place I expect senior-ish and reliable answers from.

Packages that supports Bluetooth and IP Printers

I need to take printout on the small Epos type thermal printer as soon as an order is received. Does anyone have experience doing that? Many packages seems outdated. Even if you have a react native solution, works fine, I can put the react app inside a react native webview...

Better way of typing `useRef` when passing to another hook.

Hello. I'm using react-aria to create some buttons and I would like to be able to type the ref object I pass to the useButton hook without casting it. Is there a way to do this ? ```typescript...

Passing Dynamic Variables & Filters to TRPC results in Hydration Error in Next.JS?

I am trying to make a dashboard where a user can apply a few filters. So they can, for example, request to only see the published posts or the unpublished ones etc. The way I have implemented this is like so: ```js...

Error with t3-app `env`

I just added lint-staged with next lint --fix as a pre-commit hook and the log is showing me this. I have baseUrl: "." and paths: [{ "@/": "./src/" }]

Easiest way to toggle dark mode or light mode in react or next app?

I want to change my css variables to dark mode or light mode colors. Should i put my global css variables in __next and use a selector to change the css variable values? Are there any other ways that or better or easier?

what would be the best way to refetch state that I got via getServerSideProps using TRPC?

Currently I'm passing in initial state from serverSideProps, just using prisma client to make the fetch. But then when a user makes a new post, I want to update the list of posts that the user sees. Issue is, I have nothing to refetch

React Hook Form Reset Triggering on Change?

I have a form using useform, one of the inputs updates another input when it is filled out using onchange and setvalue, however that second input is set to the first inputs value when I update default values using reset, and not setting the field to it's value returned in an API call. Any ideas on how to allow for setting a value on change and pulling correct data when reseting the form?

Just started trying to learn prisma through the docs and I'm getting an error

When I run "$ npx prisma migrate dev --name init", the terminal returns "Error: Couldn't find a datasource in the schema.prisma file"

Best way to pass down variables & filters from React-Query (& TRPC) to Prisma?

Say I want to get all users whose email address ends in prisma.io, who have also published some posts. I know how to do this in prisma: ```js const result = await prisma.user.findMany({ where: {...

Created a Resizable HTML table, missing one last thing

I created a Resizable table with event listeners, I used React because I need it in my project (mainly for useRef Hooks). Stackblitz - https://stackblitz.com/edit/react-ts-devbrv?file=useResizableTable.ts Basically when shrinking a column, it checks that the columns' widths are higher than the minimum width, and if not, recursively searches for the next column it can shrink and focuses on it....

Functional approach for concise code

Hello, Soon Im gonna rewrite my app with T3 stack and I just wonder about approaching backend/fronted Logic with more functional paradigms. Originally I wanted to use ramdajs but I read its problematic with typescript. Yesterday I found two libraries that seems very promising but wanted to hear if someone has any opinions about them and in general about FP data transformation handling.
https://github.com/mobily/ts-belt ...

Zod - sort schema

Hi. I am adding sort option to prisma findMany query. Since I don't know zod very well, I could not think of any possible type-safe solution. Sort format should be: columnFieldName:orderType, so for example: firstName:desc. I made my types from @prisma/client, but don't know how to add them to tRPC input. Is it even possible?...

tRPC client error

Someone that has any idea on what might cause this issue and how I can resolve it? (I'm trying to bump tRPC from v9 to 10 in my cross platform monorepo that is using the starter from the link below) https://github.com/chamatt/create-kaol-app This is the error I get on the client: ```...

Next JS API Route Never Returns HTTP Status

Hey Folks, I have a very basic REST API route (Its a web hook so it cant be a TRPC route) that checks if the request type is POST and if so returns a status of 200. However, when I try to use this the request times out and never returns a response. Could anyone point me in the right direction? Here is the route:...

Prisma TRPC Casing Issue

I have following schema: ```ts model Customer { id String @id @default(cuid())...

CSS Question - black or white text color based on background

Hey guys, I'd like to have my text colored based on the background color. I found a way to do it on the CSS tricks website, but it's using a mix-blend-mode - they say it's not well supported and it also does not work with only black / white coloring. Is there a pretty convenient way to do it in CSS (maybe Tailwind) / JS (I'm using React)? The screenshot shows what I have right now (I want the black text on the red-ish background to be white)...