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

running tests in the t3 monorepo

So I have made a repo using the t3-turborepo starter, and I have started adding things, including vitest, but I am getting a bug
Error: Failed to resolve entry for package "@test/auth". The package may have incorrect main/module/exports specified in its package.json.
Error: Failed to resolve entry for package "@test/auth". The package may have incorrect main/module/exports specified in its package.json.
everything else works and here is the link to the repo https://github.com/dominikvrbic/t3-turbo

Is there a way to detect in the browser when the user connects a device to their machine?

Not without their permission, obviously, but it would be neat for users to be able to connect a device and have my app automatically detect it.

Asset load progress library

Hey all, Work is using a modified version of this https://github.com/Jam3/preloader to preload assets on our interactive sites. Is there anything more modern out there that we can use? Any suggestions? Basically I want the ability to detect the loading progress of all asset types and set state accordingly....

Overflow Behavior in CSS

I'm building an app for running tournament brackets which, by their nature are often large hard to break up so my app requires a decent amount of overflow handling. I am struggling to understand how to get overflow to work in many cases though, particularly when padding is involved. For instance here is a bit of my UI for adding players (see image) The parent clearly has padding on bottom, but the scroll refuses to take this into account. I've seen this change based on seemingly random things like the flex-direction. Is there a good guide or some rules that explains all this?...

Getting a type from Zod Schema

Is there a way that I can get a type from a Zod schema? Essentially I want to set the type the return value from a function to the type generated from the Zod schema.

store images on cockroachdb using prisma

how can a user upload images on database? what type should there be in the prisma model...

Is it possible to run websocket (trpc subscriptions) server in the same process as nextjs app?

Official TRPC example on using websockets with next (https://github.com/trpc/examples-next-prisma-websockets-starter) seem to run them separately, but it doesn't really look right to me, as i'm not ever planning to run my app on edge or serverless, and just want this stupid-simple monolith.

DES algorithm

Anyone knows how to write DES in Node? I have an assignment and my brain is melting. If anyone has a gist, it will save my miserable life. 🙏

I want only registered users to be allowed to login & only admin can register new users? (Next-Auth)

I don't want users to sign up themselves. I first need to check something manually, only then do i want to send them a sign-in link. I do know how to prevent anyone from logging in: ``` async signIn({ user, account, profile, email, credentials }) { const userExists = await prisma.user.findUnique({...

NextAuth Google Provider not working

I am trying to set up a sign in with google button I have the GOOGLE ID and Secret thing in the env and I console.log-ed it and it shows, but for some reason when I try log in, it just puts that error in the terminal. ```ts adapter: PrismaAdapter(prisma), providers: [ GoogleProvider({...

tRPC and REST

We're considering building tRPC Nextjs base systems which pull data from Strapi via REST calls. So, instead of using getServerSideProps, I am thinking we will would create a router and define procedures which each make appropriate REST calls to Strapi. Is this the right approach? Your comments and thoughts would be appreciated. Thanks!...

Lotsss of files being changed

Should I see this many files being changed by webpack(?) whenever I make small updates to a few files? Is there something im not gitignoring properly or something

How to share prisma schema between T3 apps hosted in vercel

Hi hi, so I've got 2 apps I'm developing using the T3 stack (created with create t3 ap), and I want to share 1 planetscale database and prisma client /schema between them. This seems to be an incredibly complicated rabbit hole I've gone down so I must be missing something. Surely this is a common task I tried splitting the prisma configuration out to a separate repo and consuming it via git submodules or package.json, but then I end up with the issue where vercel doesn't have access credentials to install it. I've been fiddling around for half a day trying to set up vercel access to a private GitHub package via .npmrc and personal access tokens but it's a cludge with minimal discussion online, so people must be doing something else for all this......

t3 stack - Prisma user name from user id

Hello, I have Prisma schema like this and I would like to get username for the post. Now I have userId but how I get username from that? I have username on my database so I should be able to move it to the session? Using client provider with t3 stack and on my session I have now id and email but how to save it to database(?) ```ts model User { id String @id @default(cuid())...

Is it possible to have a discord bot instance running in a t3 app?

I want to move my .NET & CRA discord bot dashboard app to t3 stack. The main reason I'm using my .NET backend for is to run a discord bot instance and some cron jobs. I'm not sure if this is something Next.js is capable of. Any insights?

Tanstack optimistic update for deleting a 'template'. I cant seem to figure out whats wrong..

Hi yall! At my work we have some big files called templates. They can go up to 10 mb (yes they are that big) and when deleting one it sucks for the UX. So I am implementing optimistic updates from tanstack query but I seem to be doing something wrong and my guess is because of my lack of knowledge.. Other info: - I have a TemplateProvider function that caches data under the cache key composed of an array of values ( ["templates", pageNumber, folderId || "all", search],) - I have a useRemoveTemplate() that tries to optimistically update the ui by following the tanstack docs (https://tanstack.com/query/v4/docs/guides/optimistic-updates)...

How do you execute a command which includes special characters from within bash script?

Hi, I'm trying to execute this command from within a bash script, but I cannot seem to figure it out. Copy-pasting it manually works. Any help would be appreciated. ```shell configure_gitlab_runner () { 'docker-compose exec gitlab-runner-container \...

VSCode Format on Save Help

New to TS and create-t3. Just started a t3-app and my .tsx files aren't auto formatting on save. Any idea if I need to modify anything in VSCode, as I have only worked with JS before this endeavor? The atuo-formatting works with the exact same file if it's a .js file btw

jwt vs cookies in next-auth

we recommend using sessions in t3-app but i don't know why. theo says to use sessions but what are the exact reasons one would pick one over the other while using next-auth?

Unable to send file to backend in trpc

Hi. Im trying to send files to backend using formik , trpc but not recieving those files object in my procedure . Does anyone know solution?