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

Can't get human readable error messages on uploadthing.

The returned error doesn't come with a message that I could display to a client side user. Is this something we have to try to parse out on our own? or is there some way we can get this information. The docs don't seem to make this too clear or maybe I'm missing something. I found a really nice looking error message format in the uploadthing code but it doesn't seem like it returns this?...
No description

instant updates from route handler to frontend

So I have a webhook server that lets me know when a PayPal invoice has been paid. And I have a dynamic route (/transaction/{id}) I want to immediately change my frontend when this invoice gets paid on the correlating id....

FileRouter from uploadthing doesn't write data to the database on vercel

.onUploadComplete works fine locally and hits after uploading a file but does not so on Vercel. I have cross checked on Uploadthing to confirm if the file is getting uploaded and it does, but it doesn't insert the file into the postgres database table after uploading it to uploadthing. The same problem doesn't exists when done locally. What could be the problem? Thank you and any help would be appreciated.
No description

Catch Drizzle Error

Is there any way to handle errors that drizzle throws gracefully? In the code that I provided, the query return Project or undefined, however if the query doesnt executed succesfully (it doesnt find an entry), it goes into the catch block and my not found error never fires. How can I distinguish what type of errors drizzle is throwing so that I can throw the the right type of error?...
No description

How to send additional information with a file using UploadThing?

Hey everyone! I have had a great time implementing upload thing into my application using the docs and would love to profit from the simplicity of using the inbuilt frontend components aswell! To properly authorize the usage and categorize the file in the database, I need to send additional information about the files context to the authorization middle ware including ids of objects that the files belong to, unfortunatly I havent seen any simple way to do this using the generated components... ...

Uploadthing UploadDropzone component button stuck on loading state

I'm trying to get this thing setup in my Next.js app and while I can click on the drop zone and all seems to be actually functioning, the button and dropzone stays in a "Loading..." state no matter what I've tried.

Twitch Con EU 24 Meetup?

Hi there next weekend will be Twitch Con Europe in Rotterdam. As I have spoken to some of the community in Theos twitch chat, and discord that will be going to TC EU 24. We would love to have a channel to communicate through. Otherwise this might be something to find Twitch Con go'ers....

Replacing Context with Data Access Layer

Hi! I'm a dev with 6-7 months of React/Next experience. I'm working on a small B2B SaaS app where users can be part of multiple teams. Each team in turn can have multiple projects. I recently read this article by the Next.js team: https://nextjs.org/blog/security-nextjs-server-components-actions. I realized I was doing a lot on the client side, and I decided to move as much as I could to the server-side, to adhere to the recommended Data Access Later approach and using Data Transfer Objects to clean, verify access, and pass data to the client side. This is the pattern I'm trying to implement: "server-only" components: fetch, verify, clean, and return data as DTOs --> server components (page.tsx mostly): fetch DTOs based on current user's id or route slug, and pass data to client as props --> client components: render ui based on data passed as props, and add interactivity...

trpc with Server Actions

Is it worth creating a trpc server purely for database queries, and then having mutations run by server actions? Originally I thought that server actions would cover everything, but I know they're specifically not recommended for querying data, only mutating. However, I'm not sure if having a trpc server alongside that would be complicated from a DX point of view? Not sure if I've explained that well, happy to clarify if needed....

What’s the correct way to setup simple node+typescript app in turborepo?

Hello, I’m working on a Next project that needs a websocket server for some realtime features. I’m having trouble with setting up build process for the node server inside turborepo. Scenario While the project is a bit more complicated, I’ll use a realtime chat as an example of a feature I want to build for simplicity. ...

Module build failed: UnhandledSchemeError:Reading from "cloudflare:sockets" is not handled by plugin

I am using drizzle + postgresql + nextauth . what can I do to fix this error? The app was working fine before adding nextauth beta version...
No description

Hitting request timeout on Vercel but function is expected to be slow

I have a service running on GCP that does some really slow web crawling stuff and I keep hitting the request timeout in Vercel. The request could take potentially up to 30min. What are some patterns/tools here that I can explore?

Best practices for rendering the version of your app

I have a React-TypeScript web app in which I'd like to render the current version at the top of the home page. What I'm thinking is that I could have a version.ts file with this:
export const APP_VERSION = "1.0.0"
export const APP_VERSION = "1.0.0"
and then when I make a commit, I increase that number. But I've never seen this being done in real world open source github projects. What's the best approach here?
Solution:
Bump on CI and get value on build

UploadThing randomly started failing this morning

Is anyone else experiencing something similar? I first noticed in my staging environment while testing. @uploadthing/react components are getting stuck in an infinite loading loop, the server kept pinging back "still uploading" or something like that. I can't get back to it now. Went down a small rabbit hole and am seeing the same error consistently across all my builds. I tried to redeploy the last successful build on Vercel (4 days ago) and it failed with the same error....
No description

T3 Middleware

Hello there, I was wondering if it is possible to use middleware.ts using the t3 stack (NextJS, tRPC, Drizzle and AuthJS v4). There are two session strategies, database sessions (t3 default) and JWT sessions. I read a lot and saw some videos but still not sure if it is possible. Maybe with the AuthJS v5 something change or idk....

Hear Ye, Hear Ye! A Call for Aid in the Realm of Codecraft: The Tale of the Missing Styles

Hello everyone, I'm working on creating an NPM package using Vite with React in library mode. I've configured Tailwind CSS in the package and added a few custom CSS classes. Everything seems to work fine when I run the project locally. However, when I publish the NPM package and install it in a new project, I run into an issue. The styles defined in the tailwind.css file are applied correctly to the components. But the Tailwind classes used directly within my SpaceButton.tsx component are not working at all....

Recommended way to prettyprint tRPC errors

Do you all have any preffered way/function to pretty print tRPC errors like zod?

What NoSQL databases are actually good?

As I understand, MongoDB is not rly a good idea due to scaling reasons (maybe others idk) I asked an AI and it answered this, what do you think?...
No description

How T3Stack env.js actually works?

I'm trying to figure out what kind of black magic that createEnv function does behind the curtains, when I'm running my application. The reason is that I'm having seed.ts at the root of my project, which I'm using to seed the database, by calling tsx seed.ts. Problem is, that if I import env.js into that seeder-file, it does not have env variables available. Same thing when I'm trying to call Encryption.encrypt() method from one of my lib-files, to encrypt some data, and that lib-file imports env.js, I get error that environmental variable are not set. Should I somehow load the .env file manually on tsx call, or what might I be missing?...