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

Next 13 AppDir + middleware

I tried to create an app with Next 13 and play with the new app dir (beta), but I couldn't make middleware to work. I had no pages dir, all pages were rendered correctly but it seems like middleware was not firing. Is this not yet supported ? I couldn't find anything in the stable or beta docs of Next...

How to trigger NextJS Image fetch again if not loaded in 3 seconds

Hi, I'm fetching images from an unreliable gateway that sometimes require multiple tries (same URL) to load the image. Is there a way using Next Image/Future Image to trigger a fetch from the same src link again if it is still loading after 3 seconds or if the load has failed? Thanks for your help!...

Im converting my old code to Typescript, I need help with a functions.

Howdy, im just converting some of my old code to Typescript from JS and I am struggling with a few functions. Answers would be amazing.

Getting user IP in trpc without req object?

I used to get the users IP like so, just giving the package the req object: ``` const requestIp = require('request-ip'); const ip = requestIp.getClientIp(req);...

Set value based on current

Is there a shortcut for setting a value based on it's current value in Prisma, I have a field that's initially null that I would like to update in a webhook, but if it's already set i don't want to update it. Can i do this in a single query or do I have to first get the field and then update based on the response of the firrst query?

can i export data from reactQuery?

Please i need some help here. 🙏 I fetched data[] from an API using reactQuery but the problem I'm facing here is that i need to export all the properties decontructed from reactQuery such as the data[], isLoading, error so that i can be able to use it in another component, is this possible? I name the file userData.tsx ```export const UserData = () => { const { data, isLoading, error } = useQuery<User[], ErrorConstructor>("query-users", async () =>{...

Filter Query with multiple parameters

What is the recommend approach when creating a query that needs to filter based on some conditions which may or may not exist (if the user doesn't specify them we should ignore the filter rule) while using prisma? Something like /posts?category=a&tag=b Should filter posts with a category and tag b...

Make an object with the same structure but modified values

I'm trying to do some cool stuff with .mdx as strings being parsed in getStaticProps and got to an ok point but everything went to shit when I tried to put those strings into an object since I need to serialize them and want to keep the object structure for that sweet autocomplete in the frontend. Long context out of the way, let's say I have: ``` const obj = {...

React Native + Web + Next.JS

Does anyone know a good boilerplate template for react native + nextjs? Trying to find a working one but no luck so far.

Store data in object format in prisma (MongoDB)

How to do this in prisma model ? I'm using mongodb

How to create object in prisma models (MONGODB)

I want to create an object in my model named orderData:
orderData = {name, email, service, note}
orderData = {name, email, service, note}
I want to create a property name orderData and these properties will be there...

Why is using Prisma a good Idea

Why and what kind of problems can we solve with it? What are some alternatives?

planetscale-prisma issue

any prisma-planetscale users in here? im trynna create a new db and populate the data. (its pretty long) - like 10k links long but im getting a (i believe) timeout error from planetscales side. The code runs fine, im able to see like 200 - 300 entries, the data until the error occures. heres the error message im getting ```...

Graphql schema first or code first ?

Im currently building an app, for something i will use but as an hobby, using NestJS, GraphQL and Prisma. I have read about both approaches, and i find the schema first very interesting because it allows everyone to understand the API whatever language is used on the backend. Since im using Typescript and I will be working, I was wondering if the code first approach wouldn't make me write less code specially because Nest has a plugin that allows to not use decorators on every property, which mak...

how to extend a model

So basically i have a few models but the model is been reused but i want to manipulate it to add some more values

getting a server response without metadata (config, header, request, status)

When I make a request like this (screenshot1) I always get a nested data object along side config, header, request, status, statustext (screenshot2) That has been fine so far, but now that I have a paginated response that I'm getting via React Query useInfiniteQuery(), I get multiple data objects nested within each other on subsequent pages (screenshot3) ...

Next auth try signing with a new different account

I tried to make login functionality with google sign in but it's saying "try signing with a new different account" all the time

How to use yarn in create-t3-app ? [SOLVED]

Just started discovering t3 and noticed that it ran npm install in the initialization part. what's the way to install dependencies with yarn?

react - submitting form from parent or sibling

hey all, I am struggling to implement a design that has the submit button for a form essentially in the parent. the markup essentially boils down to something like: ```ts...

Presigned URL set acl?

I have a presigned url logic which uploads files successfully to my s3 bucket, but right now I can't view those files, I am getting an acl Access denied error. I am wondering how I can set that policy in my presigned url logic so far I did this without success: ```ts const conditions = [{ acl: 'public-read' }, ['content-length-range', 0, 10485760]]; ...