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

Checking for a cookie as a TRPC middleware

Hello, For a certain group of TRPC routes I would like to check if a certain cookie has a certain value (If it does not, I would like to prevent the request from proceeding). What would be the best way to go about doing this? At the moment, I do not believe that data such as cookie is provided in any sort of context. I would also like it if it could be middleware-like, so that any route using that procedure is guaranteed to be authenticated already. Thanks for the help!...

Chat App Input Text with emojis?

Hi guys, Happy New Year. Well, my problem is that i'm building a chat app, and i'm trying to build an input that allow the user to insert an Emoji, just like Whatsapp or any other pro chat app. Well the problem is that for doing that, you have to a div contenteditable, because i need to show the images for Apple Emoji for example, not html pure emojis. So i'm a little stuck here, because i need to have in mind the cart selection, parsing html, turing back to html, in the end is a hell. Does anyo...

Prisma many-to-many self-relation

I want to have multiple m2m self-relation fields. For a user I need fields for parents, friends, partners, etc, and all of them are users as well. Prisma let me have 2 fields like this, but generates weird syntax if I do more than 2. Anyone experienced with this?...

NextJS middleware

Hello, In the middleware file, I want to check if the user is authenticated and allowed to visit specific pages. Currently how I do it is as following:...

prisma query

Hello let's say we have a user who buys a coin with specific name. For example first he buys one coin with name 'SuperCoin'. Second time he buys other one coin with name 'CoolCoin'. Third time he buys 2 super coins. How to write a query that sums the number of coin bought based on coin name? Example:...

Are there any good opensource projects, that we can follow for a good folder structure ?

Where should the components of client, which are not pages be built ?

Get session data inside a mutation

Hello. So im trying to create a profile inside a user that is already logged in. So the flow is Create User => Login => Create User Profile Inside the app. My Models: ```ts...

Next auth session cookie is not set after successful login

As you can see the server send back a set-cookie header, but after redirecting to home session is still null and I can't find the cookie in the application tab. any idea about what might happened?...

how to send images to whatsapp from react app?

i have a image in blob which i want to send to whatsapp, is there any way to do that?

Hey..... I am trying to implement some sort of sidebar, How do I go to correct path

I am not sure how to get the [id] so I can prefix all my paths to make it navigate to the right page test.com/90923 -> test.com/90923/settings -> test.com/90923/links etc...

Nested Generic Types??

Heyo I have a class that takes in an object in it's constructor. I'd like the object to be a nested object with this type: ```ts type Route = (ctx: Context) => Response<unknown>...

Next router is possibly undefined, leading to query with undefined input

Im making a page where i need to query info from my db based on the dynamic route, but my router sometimes returns undefined leading to an annoying error where a query is fired off with an undefined input. Other than doing a || " " what is the way to do this properly using t3?

GitHub Pinned Repository Behavior

Everytime you reorder these, a fetch is made to "reorder_pinned_items". I am trying to replicate this behavior for my linktree clone so users can order their links however they want. Does anyone know of any react libraries that make drag and drop like this easier? any general advice before implementing?...

File upload, hide upload dialogue after mutation

As you can see, I'm trying to convert a file into base64, then send it to the backend as a mutation, then after a backend operation on the file, I want to hide the dialogue. Usually here I would use .then , but it appears I cannot here.

cannot draw image on canvas

help, the image given by the user cannot be drawn on canvas

nextauth lock account to device

Is it possible to create auth with next auth so user can’t login to any devices other than the one he initially logged in ?

t3 + express or migrate to tRPC?

Hi, I have an old project I am starting back up. I implemented it with an express.js backend and a CRA frontend. I am trying to work out what the best way to implement what I need is. The basic functionality is to allow a testing team to monitor the progress of devices that are being updated, to facilitate faster testing. The progress of the updates is stored on a separate server which exposes a REST API. They enter the id of the device they want to monitor, and the backend verifies the id as valid via the API, and schedules it to be monitored. I calculate how frequently the device should be checked for changes based on when it was last active, to prevent overloading the external server. The backend schedules this and will periodically check each device for changes, updating a Cloud Firestore database when required. The frontend pulls the data from the backend which additionally acts as a cache to reduce db reads. ...

AppRouter being inffered as any

I am trying to setup TRPC for my react native app in a turbo repo. But after importing the AppRouter it is showing as 'any'. I have no clue what I did wrong as I was following the guide from TRPC doc. The react-native app is a bare-rn app. And I am using yarn as my package manager with ``` "installConfig": { "hoistingLimits": "workspaces" },...

How to add extra user DB fields into context

Hey guys, trying to solve authorisation. I have an isAdmin field added to my user. My idea was I would just create a TRPC middleware similar to protected procedure but check ctx.session.user.isAdmin. Issue is, only name, email, id and image is returned on ctx.session.user: I watched the Theo vid on authorisation, but thought it would be cleaner rather than an extra separate api call to just include it in the context and middleware. How can I achieve this?...

tutorial hell unhandle runtime error

Can anyone help with this? not sure if it is Prisma model problem or how I require prisma went wrong. here is my error message `` Unhandled Runtime Error TRPCClientError: Invalid prisma.like.create()` invocation:...