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

Verifying query type in `getServerSideProps`

Hello. I have a getServerSideProps function and would like to verify the query to avoid security vulnerabilities and return a 404 page: ```typescript interface QueryType { id: string;...

tRPC with ssr: true - what's going on?

I've looked far and wide, and haven't figured this out. ssr: true uses getInitialProps, instead of getServersideProps, which can result in faster page loads since we're not waiting on the server. However, getServersideProps is now the recommended solution. putting ssr: false feels wrong as it seems like this means I won't get ssr. I imagine this is wrong? Is the ssr that trpc is referring to different from the ssr we do want as described in the next js docs?...

turbo repo package not found

I added a new turborepo package in my turbo repo repository, but I get this error: ```ts Failed to compile ../../packages/api/src/router/document.ts:1:0...

Question About Drizzle Composite Keys

I posted this over on the drizzle server and wanted to crosspost it here in case anyone can take a look at it. Thanks! https://discord.com/channels/1043890932593987624/1134887847271346186/1134887847271346186...

ESlint: Require explicit return types on exported functions, yes or no??

Per Theo's video I'll post below and the well articulated logic within, it's best to avoid using explicit return types whenever possible. I just jumped in on a codebase that has eslint rules that yell at me when I don't explicitly type the return type of function's that are exported ie export function foo() and export default function. Should I (suggest we) disable this and let the return types be inferred as Theo suggested of functions in the below video? Specifically I am asking about this eslint rule: https://github.com/typescript-eslint/typescript-eslint/blob/v4.33.0/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md https://www.youtube.com/watch?v=I6V2FkW1ozQ&t=495s...

Confused about return types of findFirst and similar

I'm struggling with getting data back from tRPC router with Prisma. I expect the strongly typed Article object to be assigned to const x. IDK if it's a {props} thing or what. Honestly there are so many technologies in play I'm not sure where to start. Questions: 1. What data type is findFirst() returning in this instance? 2. How do I properly pass it via props to the functional component?...

Why Use Server Actions?

I can see the benefit of the server component version. Colocated, no need to make an api endpoint in another file. ```js import { cookies } from 'next/headers' // Server action defined inside a Server Component...

Hosting platform for docker images (discord bot specifically)

Ok so I used to have a mega chonky vps but im swapping away from that now. The primary use was a rather resource hungry Discord bot and it needs a new home. so for its web dashboard, its swapping to vercel BarbaraPoint for the postgres database, well i was gunna use neon but that looked quite pricey so ive swapped to planet scale and mysql. I use prisma so it was v easy to swap ...

How to config ESLint with Webstorm (create-t3-turbo)

I recently switched from VSCode to Webstorm. I found as my monorepo kept growing the ESLint and TS server on VSCode became super unreliable to the point where it was crashing multiple times a day on me. I like Webstorm but was having trouble setting up my ESLint config path. Has anyone set up the config paths properly? For some context, I have a .eslintrc.js file in my root that extends an index.js config file in packages/config/eslint. Here is the eslint package config: ``` /** @type {import("eslint").Linter.Config} */ const config = {...

One to Many connection not working correctly in Dirzzle

So i am trying to get a one to many relation working with drizzle and it keeping this error: Error: There is not enough information to infer relation "recipes.ingredients" this is my relation for the recipes these are all my relations for the recipe ```ts // recipes relation...

problem with slugs

getting this on a page with slugs. (on form submit I redirect to /transaction/stuffhere on that first redirect instance everythings fine. but now if i go back to that page in a new tab closing the previous, i get a hydration error in production but it doesnt break the page...

Where should I place middleware? (following T3 app tutorial video)

I was placing middleware inside 'src' folder (like what Theor mentioned) but it kept routing me to a unknown url instead of localhost:3000.. So instead I placed the middleware in the root folder (as it's mentioned in the Clerk docs: https://clerk.com/docs/nextjs/trpc#configure-middleware) and it appears to be working fine since I can see the purple background. Not sure whether this is correct tho.....

stop using prefix with tailwindcss

Yes, just DO NOT USE PREFIX WITH TAILWIND, unless you have a really good reason to it makes your components not useable, for people who just want to use them. or if you want to make it a component and use it in another project, it will add unnecessary extra steps. ...

Does server actions input have to be validated server side?

Are they like exposed api endpoints or are they private? Would validating client side using input props like require/max-length work?...

T3 Stack Tutorial - Posts won't retain

Hello! I am new here and new to TS and React. I am attempting to follow along with Theo's amazing T3 stack tutorial but have been running into an issue I was hoping someone would be able to assist with. Upon running the app, I keep getting the error: prisma:query SELECT trilldb.Post.id, trilldb.Post.createdAt, trilldb.Post.content, trilldb.Post.authorId FROM trilldb.Post WHERE 1=1 ORDER BY trilldb.Post.createdAt DESC LIMIT ? OFFSET ?...

[SHADCN/UI] Form Input add symbol

I've got this input that represents an estimated return in percentage, and I want to add a % symbol after the input, anyone know how this can be done without some weird css hacks?
Solution:
I managed to do this with some relative positioning, obvious solution but not really what I want, I want it next to the text not as some icon, anyone know how?

next js 13 request body size configuration

how to customize the maximum size of the request body in next js 13 api route ?

Wordle - Word selection

Hi! I'm currently developing a wordle clone where you are able to guess between programming languages. I am almost finished with it but there is one thing that I can't really wrap my head around. I need to find a way to select a specific solution for each day based on a certain timestamp each day. I also want it to be the same for all users. Any help is greatly appreciated 🙂...
Solution:
hash the date and convert the first couple of bits to decimal. That will be the number of this day's word in the wordlist

What projects would be good for learning backend development?

Hey all, so I asked what skills I needed to learn to be a successful backend engineer. and I was shown this roadmap https://roadmap.sh/backend Now I am wondering what projects should I aim to implement to solidify my skills. I can read about all these concepts all I want, but I learn best by implementation, just have no idea what to implement....