stanisław
stanisław
TTCTheo's Typesafe Cult
Created by stanisław on 1/30/2024 in #questions
nextjs all pages are dynamic
I am using create t3 app with app router created like ~3/4 months ago. This implementation makes all pages that use api exported either from react.tsx or from server.ts dynamic even if I am not using headers in a current procedure. What can I do to make pages dynamic only if the current procedure uses next/headers
2 replies
TTCTheo's Typesafe Cult
Created by stanisław on 1/28/2024 in #questions
Next auth createUser event not running
No description
3 replies
TTCTheo's Typesafe Cult
Created by stanisław on 1/18/2024 in #questions
revalidate trpc call every 1h
Hi, I've a server component and I want it to fetch data initially on the build time and later on revalidate it every 1h. In nextjs docs there is an option revalidate in a fetch api but how can I use it using api from server with newest 3app
2 replies
TTCTheo's Typesafe Cult
Created by stanisław on 1/17/2024 in #questions
Infinite query with app router initial data
Hi, I am having a hard times implementing ininite query with initial data passed from server components. Does any1 have an example of e.g procedure and implementation using app router and initial data? Thanks in advance
8 replies
TTCTheo's Typesafe Cult
Created by stanisław on 11/1/2023 in #questions
trpc error throwing and catching on the client
No description
3 replies
TTCTheo's Typesafe Cult
Created by stanisław on 10/9/2023 in #questions
React hook form context zod
Why is the error in Input not showing after submitting form? It looks like context breaks a subscription somehow. Any help? 🙂 https://codesandbox.io/s/react-hook-form-re-validate-issue-7y7ssx?file=/src/App.tsx
2 replies
TTCTheo's Typesafe Cult
Created by stanisław on 1/21/2023 in #questions
Typesafe query keys
Hey I am curious how do you guys manage your query keys and keep track of them. In a complex application managing them and keeping track of which one to invalidate seems hard for me. Is there an option to make them somehow typesafe? I haven't found any good articles on this topic :/
8 replies
TTCTheo's Typesafe Cult
Created by stanisław on 12/27/2022 in #questions
Typescript array typing
Hey I was wondering why typescript doesn't indicate that the name here is possibly undefined when the arr is empty?
type T = { name: string }[];

const arr: T = [];

const name = arr[0].name; // no ts error but it throws Cannot read properties of undefined
type T = { name: string }[];

const arr: T = [];

const name = arr[0].name; // no ts error but it throws Cannot read properties of undefined
8 replies
TTCTheo's Typesafe Cult
Created by stanisław on 12/16/2022 in #questions
Handling prisma errors
Hey, quick question. Let's suppose that in my db I have model User with few unique fields: name, surname, email Should I validate manually that those fields are unique and throw an error if not or should I just let prisma do it? I guess that the 2nd solution is better. How do I map prisma errors to show more human friendly messages than this:
{
"statusCode": 500,
"code": "P2002",
"error": "Internal Server Error",
"message": "\nInvalid `prisma.user.create()` invocation in\nC:\\Users\\-.-\\Desktop\\icerty\\apps\\server\\modules\\users\\users.routes.ts:78:40\n\n 78 const offer = await prisma.user.create(\nUnique constraint failed on the fields: (`name`)"
}
{
"statusCode": 500,
"code": "P2002",
"error": "Internal Server Error",
"message": "\nInvalid `prisma.user.create()` invocation in\nC:\\Users\\-.-\\Desktop\\icerty\\apps\\server\\modules\\users\\users.routes.ts:78:40\n\n 78 const offer = await prisma.user.create(\nUnique constraint failed on the fields: (`name`)"
}
1 replies
TTCTheo's Typesafe Cult
Created by stanisław on 12/11/2022 in #questions
Zod like parser in typebox
Hey, I have a schemas made using @sinclair/typebox and I am looking for a similar option to .parse method provided by zod that throws an error. I see that @sinclair/typebox offers .Check method but it does not throw an error. Also there is an .Errors method that returns me an array of validation error but still I'd have to throw it manually. Am I missing something there?
1 replies
TTCTheo's Typesafe Cult
Created by stanisław on 12/10/2022 in #questions
Server vs client components
I am building an app that lets users create an offers just like on amazon. Is it a better idea to fetch those offers on client side or server side? Or it depends on the scale of an application?
3 replies
TTCTheo's Typesafe Cult
Created by stanisław on 11/30/2022 in #questions
Prevent possibly undefined user with useQuery
I have a hook useUser that looks basically like this
return useQuery(// fetch user)
return useQuery(// fetch user)
Lets imagine that its used in a Layout so when the user is loading the whole app is just a loading spinner. Now I want to get the user inside a component nested in Layout Using useUser hook makes no sense here because its return is always User | undefined as typescript doesn't know the user is loaded somewhere higher. How do I solve this problem? Checking
if(!user) return
if(!user) return
Doesn't seem good because the user is always here if the component rendered.
179 replies