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

Returning Prisma generated in nextjs issues error 'TypeError Do not know how to serialize a BigInt'

I tried following the thread here https://github.com/prisma/studio/issues/614 and it sounds like I have to monkeypatch BigInt to get it to work. Is there a better way?

trpc.useQuery() succeeding but returning empty data?

Ive checked my db and the entries definitely exist. and the query is sending the right Id input to find a unique entry using the id. But the data object in the useQuery result is undefined...

Is NextJS Api worth? When do we use it?

I've been learning NextJS lately, I used to create and use my own RestApi with express while coding for React. When I create NextJS Api Can I skip express? Can I use it instead of Express or should I use it? Does it allow middleware operations? Can you tell me if it has a different purpose?...

Custom fonts not working in new version of tailwindcss

I want to use custom fonts in my app but the custom fonts wont work. tailwind.config.cjs: ``` /** @type {import('tailwindcss').Config} */...

rich text react

How would a component that lets a user customize rich text work? Would it just be markdown? What about wysiwyg? Is it just turning everything to markdown in real time?

How do i parse Fetch response with superjson

So the issue is that when i fetch data it wraps data into object with key "json" and value of data: ``ts const groupResponse = await fetch(${baseUrl}/groups`); //Handle errors...

how to http fetch from nextjs app running on GitHub codespaces without being prompted to login

Hello. When I try to hit an API from nextjs codespaces that lives in the same app and url, I get a prompt for logging in as a response which breaks the response follow. How do I fix this?

Prisma where every filter on many-to-many

I think I am being super dumb, but I have a many-to-many relationship of Entry to Campaign. I want to find all entries connected to a given campaign. I thought I could just do ```ts const entries = await ctx.prisma.entry.findMany({ where: {...

NextJS build works locally but fails when deployed to Vercel

I searched this up but found no solutions that applied. Vercel crying:...

Creating a new record that's related to an existing record and creates new relations?

Can you use this to created multiple levels of related records? https://www.prisma.io/docs/concepts/components/prisma-client/relation-queries#connect-an-existing-record i.e. the story app I'm working on. Users create a story which should connect to their user id, and they also write a chapter which connects to the story:...

Call trpc query after click or change

I am trying to fetch some data on a change event
const handleClientChange = async (value: string) => {
const result = trpc.client.getOne({ id: value }).useQuery()
const handleClientChange = async (value: string) => {
const result = trpc.client.getOne({ id: value }).useQuery()
...

Sanitize Credentials from Prisma Output

Is anyone here using credentials auth in their t3-app? Is there a way to santize the field output through either Prisma or Postgres to ensure you're not returning passwords back from queries that request the User as a related field? Just wondering if there's a convention for this. Also if anyone has experience with implementing credentials auth I'm curious to see what your auth flow looks like. I've setup credentials auth, but am having having trouble wrapping my head around getting next-auth to use the session strategy for oauth and magic link, but create a JWT when credentials are used. Thanks in advance !...

Little confused with tRPC and tanstack-query. plz help

I'm a little bit lost on what to do here. What things do I need to know in order to successfully send data to the backend, i.e. POST/PUT. I know it's going to use a mutation, but I'm not sure what's the best practice approach using trpc?...

What is this React pattern called?

```jsx <Popper id={id} open={open} anchorEl={anchorEl} transition> {({ TransitionProps }) => ( // <---- This calling function which lets you pass the data to components provided by user <Fade {...TransitionProps}> <div className={classes.paper}>The content of the Popper.</div>...

filter approaches on endpoints

Is there a preferred approach when it comes to adding filters to endpoints. There are two approaches I can think of. 1: Create a endpoint for each filter option, eg. "get-most-viewed", "get-most-recent", "get-highest-rated". 2: Have a singular endpoint that takes in an optional input and based on the value on the input queries for the data we want....

server side calls trpc

Hi, is there someone who can explain to me how do I make server side call with trpc in t3 ??

zod to check if string is only whitespaces

how do i use zod to check if a string is only whitespaces?

is there a way to typesafety in Swagger Ui

i wonder if there is a way to write api's docs with swagger with typesafety in it ? of course that wouldn't be a comment , maybe an object type or somethings and the docs would be in .json and do you any alternative to write docs for an api beside swagger...

getServerSideProps NextJS

Is getServerSideProps used only to fetch data? I mean is it worth calling it e.g to fetch images from public folder?...

Union TS generic function definitions into one type with all possible input -- output types

Working with GQL for my employer and using graphql-hooks which is being invoked inside a custom hook that handles adding headers for us as needed. I'd like to create a type definition that will allow us to denote what the expected response in the data key will be based on the input string passed as an argument. I went ahead and created a def that accepts two generic parameters, one which represents the input string literal (T) and the other which represents the expected shape of the data (U):
type UseGQLGeneric<T, U> = (
request: T, // GQL query string
requestOptions?: object
) => [RequestFn<U>, UseClientRequestResult<U>]; // U being the response body
type UseGQLGeneric<T, U> = (
request: T, // GQL query string
requestOptions?: object
) => [RequestFn<U>, UseClientRequestResult<U>]; // U being the response body
...