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

nextAuth - Add to the user model

https://next-auth.js.org/adapters/models Hello, I'd like to add modify the user before it comes into the session callback in [..nextauth] ``` callbacks: {...

Data fetching strategy with Next.js for a dashboard-like app

Hi I hope this is the right place for a discussion like this 🙂 In the past, I was mainly developing mostly static websites with a few interactive elements. Now I'm planning to do a personal project with a more app-like behaviour and was wondering what the best practice is regarding data fetching with Next.js, especially with the T3 Stack....

Parent model in child model in Prisma?

Sorry for the confusing title, I'm looking to do something like this: ```ts model Parent { id String @id @default(cuid())...

Noob Question Many-to-Many in prisma after nextAuth

Hello all! I'm trying to create my first many-to-many relationship in Prisma. schema: ```schema...

Proper way to handle a protected route with react-query

Greetings all, I need to protect a specific page and show it users only if they have a certain "status" which is fetched through a simple query to the server. See this code example for reference: ``` import React from "react"; import { api } from "../utils/api";...

Custom data fetching hook

Hey guys, It would be really helpful if someone can provide some examples as to how to configure a custom data fetching hook, such that it returns repeat queries from cache directly, ...

Why am I getting these TypeScript ESLint errors even though VSCode doesn't complain?

Here is my repo. It was bootstrapped with create-t3-app: https://github.com/ChromeUniverse/luccanotes And here is the full output of npm run lint: ``` ...

Why useQuery runs multiple times?

my first time of using react query and facing issue of running API request multiple times, I dont know what causes this issue am I doing anything wrong? ```ts export const sendAuth = async ({ token }: { token?: string }) => {...

Is these animations a lot for a library like react?

I want to make an algorithm visualizer, like this one: https://www.toptal.com/developers/sorting-algorithms I found this lib called framer-motion. I might be wrong but it seems that I need to re-render a lot to be able to build the project above. I probably need charts because it's animating based on data. but I don't know a charting lib that is flexible enough....

TRPC + Redis

Hey Guys, I'm exploring using redis to make my data real time and using trpc as a rest like API. I was reading through the trpc section on subscriptions and it seems like there should be a way to integrate redis directly into TRPC, but would that require me to have a websocket server active to manage it? Is it better to just not use TRPC subscriptions and just build the pub/sub logic into my state management?...

Problems with useQuery.onSuccess()

Hi there, I'm doing a query on my trpc router and when it succeds I want to put that data on a useState that expects a ReactElement based upon the data from the query. The data from the query response is an array with objects like {id: string, title: string}, when I get them I run a data.forEach() on the returning array but when I have more than one object on the array only one is displayed on the client. Here is a snippet of what I'm doing, perhaps someone can see what's wrong with my code...

do you have experience with the python prisma client?

hay gang, has anyone used the python client for prisma? what's your take? https://github.com/RobertCraigie/prisma-client-py ...

Conditionally required types

Someone that has any ideas on how I can make everything required if accepted is true, if it's false then the other 3 fields are not required. ```ts type GeoLocation = { accepted: boolean; accuracy?: number;...

Static typing key: value of an object while defining

Ideally, want to statically type the keys and values in THEMES object in compile time. Currently, keys are of type "string", which I don't want. `export type THEMES_CLASSES = | "light-yellow" | "dark"...

Require one of two properties

What would you folks say is a clean way to accomplish that either userToken or ConversationId are set in my type without requiring both? 🤔 ```ts export type PostChatData = {...

Zod array of dates

Can someone help me validate that a variable is an array of exactly two dates and ideally in the future. Here is what I've currently got. However it allows an array of two nulls which isn't what I want....

Posting PDF to S3

Hello, I Hope this is the right section for Question, it feels like it is. I am working on an Project, part of it is an REST Api and different front ends (admin page, employee page, customer page ). We are using aws s3 to save relevant files, like customer bills, employees qualifications, etc. Primarily PDF (if not only). ...

Hello

I am getting TypeError: Cannot read properties of null (reading 'useContext') When trying to getServerSideProps in next export const getServerSideProps = () => {...

Hello everyone, I need help, I stuck at rendering a component insider a div. My code is like below,

const labelItem = Array.from(document.querySelectorAll('label')) .find(el => el.textContent === 'External Org Name'); const parentDiv = labelItem?.parentNode?.parentNode?.parentNode; return(...

Moving a repo inside a repo!

Hi guys, I have two projects that i want to merge: 1. A nodejs scraper 2. A Next project ...