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

Best Practices for Structuring the /api folder in Next.js

While we all have our preferred methods for organizing Next.js projects, I haven't been able to find a comprehensive guide specifically focused on structuring the /pages/api folder and keeping API-side code well-organized This might be because many of us come from a frontend background and approach the /api folder with a "make it work" mentality. Would love to hear your thoughts on how you structure your /pages/api folder in your Next.js projects. Are there any recommended practices or design patterns you've found that have streamlined your API development workflow? For example, do you group related API routes into subfolders? How do you handle middleware or shared logic across API routes? What are some great guides (similar to bulletproof-react) or repositories that I can refer?...

ESLint config

Hey guys, recently I watched one of Theo’s videos where he mention sth about the eslint-config plugin. He mentioned the fact that this Airbnb config “standard” is not really useful, even Airbnb itself does not use it. So happy to hear opinions about good ESLint rules for NextJS with prettier project…

what is YOUR_TOKEN

I want to use an API to retrieve files and perform related operations. I looked at the examples, and it seems that I need YOUR_TOKEN. However, my generated API has two: UPLOADTHING_SECRET UPLOADTHING_APP_ID...
No description

TypeScript types error using zod.

Good Evening, I have run a few different versions of the below fetch and parse of the json, I am recieving an error of "Unsafe return of an any[] type value" with both of these functions, I'm not sure what I am doing wrong. I also included my zod schemas to see if maybe thats where the problem is. I appreciate any and all help ...

Best PDF Parsing Practices?

I have a system that gets a bunch of legal documents. The documents are all for the same legal case type but they are not the same documents, as each lawyer has their own wording, they look and are formatted diff but have the same important info of course. I want to extract certain data. What is the best approach for this? As of now I am leaning towards: Anyscale JSON Mode that returns json object of vals I ask for, thoughts? https://www.anyscale.com/blog/anyscale-endpoints-json-mode-and-function-calling-features ^ Credit to Rauch 🙂 https://github.com/rauchg/next-ai-news ...

Brand new T3 stack project warnings

After creating a new project, running npm i I've got these warnings: ```npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/config-array instead npm warn deprecated [email protected]: Rimraf versions prior to v4 are no longer supported...
No description

Get HTMLElement from Element

Hey! It may be dumb? Idk. Anyways, I got an Element object from document.querySelector(), tho what I need to suit my needs is an HTMLElement. And when doing ↓...
Solution:
querySelector() either returns nothing or a dom element. if it does not return an element you can simply use ```ts const el = document.querySelector("#element") if (!el) { return...

How to get hotloading to work with t3 + sst?

built project using create-t3-app. did some small extra stuff (pointing prisma to supabase db, changed discord auth to google auth) installed sst so i didn't need to run it from npx package.json: ```json...

Best headless CMS for t3-stack?

Hey, Im currently looking in to which headless CMS i want to implement with the t3-stack, do you guys have any recommendations?...

UploadThing - Cant pass userId

Hey guys, my lack of knowledge is showing here 😓 I am trying to pass the input prop to pass my user ID but I cant use that prop since I am not really using the base UploadComponent as I followed the nextJS docs and it uses a generator. So it says input is not a valid prop, how do I fix this? ...

NextAuth with Discord & GitHub

Hey, I want to use both Github and Discord on my app, and I want to attach the profiles to the sessions so that they are accessible from the client. The user must first sign in with Discord and then the GitHub account can be linked. Can somebody please explain how I can do this? ```ts import { PrismaAdapter } from "@auth/prisma-adapter";...

disable logging in next 14.2

anyone have any idea how i can disable the logging added in 14.2?
GET / 200 in 3422ms
POST /api/auth/_log 200 in 21ms
GET / 200 in 3422ms
POST /api/auth/_log 200 in 21ms
...

Has anyone tried using prisma just for migrations, and using drizzle for querying on Postgres DB?

I have a postgres database used by another non JS backend and we were using drizzle to manage the schema and migrations as well as querrying it from this another BFF where drizzle is installed. But facing a lot of issues, seems like Postgres is not a priority for drizzle at the moment seeing some perpetually open issues https://github.com/drizzle-team/drizzle-orm/issues/295 that are unaddressed. I love the query structure of drizzle and the performance gains are also nice to have. Is it advisable to use prisma just for the migrations? Has anyone had any success with this? If so how is the experience. Would really appreciate more insight into this....

Redis EventEmitter?

Hi, I'd like to use trpc's subscription endpoints properly. I want to deploy it on an AWS ECS service and so I'll be needing a global event emitter. I'm hoping to use upstash for this, but I'm not finding any good libraries for it. Best I could find is this one: https://github.com/jksdua/redis-events...

NextAuth with Discord THEN GitHub

Hi, I'm looking to add an option to link a GitHub account after logging in with Discord. From this, I'd be looking to gain access to just two variables – the GitHub username and profile url. These should both be logged in the database and passed to the session. Can somebody explain how I can set this up so that the data is committed via Prisma and available in the session? ```ts // auth.ts import { PrismaAdapter } from "@auth/prisma-adapter";...

ENV Variable for DATABASE_URL won't update when I run npx prisma db push

I updated my .env variable for the Prisma DB Database URL but when I run the prisma commands I get errors such as p1000 that show it is still trying to connect to my old PlanetScale DB. Any ideas on how I can get it updated? I tried to Google and search GitHub but it has not helped so far....

Nextjs parallel and intercepting routes

Github:https://github.com/Raphico/byte/tree/main Live site: https://byte.raphico.tech/dashboard I'm working on a project(👆) where I’m trying to make nextjs parallel and intercepting routes to create a modal. But I can't seem to make it work. When I click on the workshop card, I‘m redirected to ‘/workshop/[workshopId]’ with both a standard route(in the workshop route under the app route group) and an intercepting route (in the @modal slot under the app route group) that triggers a modal. However, instead of displaying the modal, nextjs displays the normal workshop page. I'm guessing I'm doing something wrong that causes nextjs to miss the modal. I've gone through the docs, sample code, and similar github issues but still can't find the root cause ...

t3 auth problem

i have a problem with next auth when i click on the sign in i get redirected to the discord login i click sign in with discord then i get redirected to : https://discord.com/oauth2/authorize/signin/discord but i get invalid form body im new to next auth thanks to everyone...

Dialog shadcn not showing up as a dialog but just as content

It seems like tailwind classes are not resolved in the dialog This is my div ```jsx <div className="flex gap-4">...
No description

Storing ab access token in memory server-side in NextJS

How can i store a token in-memory server-side in a Next.JS project? I tried doing this: ```ts export let accessToken: AccessToken | undefined; ...