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

getting the most value out of theo's T3 stack tutorial - pre reqs?

Hi, So i've been making my way through the tutorial at https://www.youtube.com/watch?v=YkOSUVzOAA4 I'm making progress following it, but am worried about how much should make sense to me as I go through it ; The bits around prisma , vercel and clerk all make a lot of sense to me, so i'm happy with this, but the JS/TS specifics bits, are not intuitive for me....
Solution:
There are a million ways of going about it, depending on what fundamentals you want to train. You could try a small "pure" Express/React web site. That basically removes all "magic" except React. Would force you to write a good bit of "vanilla" JS/TS on the backend and some react stuff for front end. If that feels too simple, one can try a regular NextJS website without the things that would make it "T3". But honestly you can you just go for it all at once and figure out the parts you don't understand as you need em. It might seem daunting, but everything really can be split into managable pieces...

How to create dynamic number union in typescript

Hey guys, so I'm starting to think this isn't even possible (especially with the comments chatGPT added saying its not possible lol) so basically I have a function, which im going to call 'test' test receives a generic that is expected to be a union type. We will call this type R...

dnd-kit in iframe

We have a react application that uses dnd-kit which we are loading inside an iframe, but it's not working now. Has anyone achieved this?

Full crud request examples & best practices for t3/trpc/react-query?

I've been struggling attaining trpc/react-query/prisma nirvana because my brain just can't seem to grok what's happening between the different technologies. I come from a Ruby on Rails background, so I'm used to thinking about making skinny controllers and fat models. This inherently is difficult for me to grasp if I should be building out logic in my api/server/router for each Model, or if I should be building functional components that do specific things with the data I need, like, return results that match chained filters. I guess my biggest question is "Should I think of queries that return data or manipulate data as components, logic that should be abstracted into a hook, or logic that should be coded into routers?"...

AutoIncrement using mongoose

Please Guys what is the best way to implement AutoIncrement using mongoose, i tried the best two option and it wasnt working mongoose-sequence mongoose-auto-increment ```js const AutoIncrement = require('mongoose-sequence')(mongoose)...

Fresh T3 install, auth.ts error: "next-auth" has no exported member getServerSession ???

Anyone know why I'm getting this typescript error was the function deprecated or removed recently?

env.mjs - Use as const

Hey I'm adding t3 env to my project and had a question about as const. Doing z.enum(['production', 'dev']) only results in the returned type being a string, not a string constant. Would I make a TS file w/ my types and import that into env.mjs? Thanks!

Is it possible to upload JSON files on uploadthing?

Is it possible to upload JSON files on uploadthing?

Leveraging Stateless Components in a Monorepo for Server Interactions

I'm currently working with an NX monorepo that includes a shared UI library. This library incorporates Storybook and other necessary components. The structure of my project currently requires me to amalgamate small UI components into an application page component located within apps/, such as UserMenuPage.tsx. This process, however, feels redundant as it necessitates the configuration of Storybook for each app. As a remedy, I'm contemplating the idea of converting my pages into stateless or dumb components. Under this architecture, these components would not engage directly with the server. Rather, they would serve to extract data which would then be dispatched to the server via a handler function, housed in App.tsx, specific to each application. Essentially, App.tsx would return <UserMenuPage.tsx onSubmit={handleSubmit}/>, where handleSubmit is the function within App.tsx that takes charge of dispatching data to the server. I'm interested in garnering the community's perspective on this approach. Is it advisable and efficient? Are there superior strategies to architect this setup, or potential drawbacks that I should be aware of in my proposed structure? Any insights or alternative propositions would be greatly appreciated....

Can you use uploadthing with javascript and not typescript

I'm only using javascript for my app, i wonder if I could still use uploadthing
Solution:
you can ignore the types

Can I still get features like SSR/ISR with this infrastructure?

Hi everyone, I need to understand a bit about SSR/ISR with this infrastructure I have built. I was first wanting to understand security implications to scaling multiple apps for my frontend, serving the HTML/JS to the users, while they consume my master backend, with all of the business logic...

Implementing next auth adapter with a cache

so I've implemented an adapter for next auth which would try to cache certain things in memory via the code below and I was wondering if I made any notable or obvious mistakes with my code (if you don't notice any issues or think I did okay you can just react with 👍 if you don't want to send a message)...
Solution:
okay so I'm gonna assume that there aren't any security issues with what I wrote, regardless I found some other issues 1. due to the way next-auth calls Adapter functions using the normal method for having a method on a class doesn't work you need to have member variables which are set to arrow functions instead 2. my lazy way of dealing with setTimeout via calling the window version was dumb and I ended up using ReturnType instead 3. setTimeout(at least the one Node provides) doesn't like getting a number that's bigger than a signed 32 bit integer can handle so I had to add a safety guard in the Cache setLifespan to max it out at 2^32 - 1...

Made a small CSS styled component

I know it's not the biggest thing but I got some feedback about my naming in a question before and I wanted to see if my css structure is better this time. CSS Code: https://github.com/juandevac/grupo_06_e-commerce/blob/main/public/css/home/footer.css Any feedback is appreciated! 😸...
Solution:
its tough to judge css without being able to see the page

Vercel Deployment giving prerender error

I am getting this error when I deploy on vercel but its running locally.@acme/nextjs:build: Error occurred prerendering page "/sign-in/[[...index]]". Read more: https://nextjs.org/docs/messages/prerender-error @acme/nextjs:build: TypeError: Cannot read properties of null (reading 'useMemo')...

Feedback for my infrastructure needed!

I'm trying to understand best practices for creating one infrastructure for my startup. Would like some feedback! I want to have one single backend for all my business logic and have the possibility to have multiple frontends for different apps like so:...

Utility type to "undiscriminate" a discriminated union

So this might be kind of a hacky thing, but I've got a use case that could greatly benefit from it. Basically, imagine I have the following type: ```typescript type DiscriminatedUnion = { type: "image" imageUrl: string...