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

Github CI with PNPM?

Hey everyone, I'm new to GitHub CI and I'm trying to write a simple workflow for a T3 stack repository that uses PNPM. Can someone please share a sample GitHub CI workflow that I can use as a reference?

which code is best to create a class for an express app

code on the left or the code on the right?

Is there a way to force data to update on a new page with t3 without having to click the page

I guess in principle this shoudn't be possible without some aspect of concurrency and clicking on the page does retrieve the data right away . But is there some way to avoid having to click on page for rerender or is that just nature of how code is rendered as I think it is?

Trying to make a website builder (a Wix clone)

HI all, I am building a Wix clone, I just finished with the interface of the Page builder, but I dont know how to start making the actual functionality of it. In another words , I want to make a drag and drop for HTML elements and style them using the UI not with code. Where should I start, what should I search for?...

UI for updating role

Got a quick question. I have a table displaying all the users in a course. Two actions can be performed on a user from the table. 1. They can be kicked from the course 2. They can be promoted to role "instructor" (if they are a student) or demoted to role "student" (if they an instructor). ...

TRPC ratelimiting endpoints (race conditions)

I am currently having some problems with a race condition in my TRPC nextJS api. Essentially what is happening is I have a enforceGuildPermissions method, which basically checks if the user who is making the request has permission to get the data for that guild. The data is stored in my Redis cache for 3 seconds. This works okay sometimes, but other times because there is 3-4 different trpc requests running for a single page which are guild, role and channel. It causes the last request (channel) to get rate limited by the discord API because they are all running concurrently, this means it doesn't give my caching code chance to update it before the next one runs....

Help to deploy my TRPC proj from a monorepo (turborepo) at Vercel

I'm trying to learn monorepo with TRPC, both are new for me and Im kind struggling to deploy it because Im super newbie in deployments. I have a turborepo with two apps, one is my react app and other one is my node server in express + TRPC. I dont know if I did correctly but I went to vercel and Ive choose the FE project; for the build options I left what had there already, seems Vercel knows what to do when its turbo repo and it went all good!!...

why do i keep getting errors like errors like this on t3 turbo when trying to install packages

I keep getting errors when trying to install packages, im on apps/expo right now
error An unexpected error occurred: "https://registry.yarnpkg.com/@acme%2fapi: Not found".
error An unexpected error occurred: "https://registry.yarnpkg.com/@acme%2fapi: Not found".
...

How do I skip build step by files changes?

I want to prevent build step triggered on Vercel evetime I update files like Readme or .vscode I tried to google for it but only found solutions for skipping build by branches but not by files changes. Tried .vercelignore but it is useless, it just excludes file from build, build still trigger anyway....
Solution:
I suggest the solution is not to maintain some configuration of which files are supposed to trigger deployment, but instead always deploy when updating main branch you can configure to not deploy when updating your dev branch or whatever. I have put a file like this in some of my repos //ignore-build-check.sh...

How do I coerce this function to accept multiple types then conditionally change the output?

Using traditional overloading approach doesn't seem to work as expected. Union types on parameters does not resolve the output type properly:
const convertInfluenceType = (type: InfluenceTypeEnum | number)
// Outputs InfluenceTypeEnum | 1 | 4 | 7
const convertInfluenceType = (type: InfluenceTypeEnum | number)
// Outputs InfluenceTypeEnum | 1 | 4 | 7
...
Solution:
i was looking around a bit and found this pattern with overloads

Using Custom Fonts Imported From NPM in The App Router

Hello! I am attempting to use the cal-sans font with the app router. Before, importing it in the _app.tsx file and then including it in the tailwind config worked, but this seems to not be the case with app router....

prisma type error on union type stored as json

I am trying to convert my Cloud Firestore project to supabase due to some issues I have had with transactions. I have the following types in my code: ```ts export interface RoundOptions { name: string;...
Solution:
Figured it out. In case anybody cares, prisma requires types not interfaces to make this work

next-prisma-websockets-starter explanation

This is the repo I'm trying to copy websocket setup from... https://github.com/trpc/examples-next-prisma-websockets-starter Inside of the server folder in this template, [https://github.com/trpc/examples-next-prisma-websockets-starter/tree/main/src/server] there is a prodServer.ts file and a wssDevServer.ts file. How are these files used?? When and how is the prodServer.ts file used(ran) and how is the wssDevServer.ts file ran? Because in the trpc.ts file [https://github.com/trpc/examples-next-prisma-websockets-starter/blob/main/src/utils/trpc.ts] the wsLink is used but there are no checks for dev or prod. And WS_URL is imported from publicRuntimeConfig. This is confusing. ...

Best testing framework(s)

Hey guys, I'm relatively new to testing but I want a testing framework with the most features in one thing. What would fit the best?

Trpc mutate is only triggered, no return (Base64 string with length equal to 14079152 as input)

Do you have any idea what may cause this? I'm converting videos to audio and then base64 string and I would like to send them to our trpc router. It's working fine for shorter videos (smaller string) but longer videos only trigger mutation. It's not even printing the console.log right at the start of the mutation....

best way to protect my code and avoid piracy when selling it

So i am trying to make a reusable SaaS product with both front-end, backend, and admin panel all a bundle that will be sold to different businesses for use So how do i go about making it so my code can't be resold and the code is only usable by the originally buyers I will be building with nodejs for the backend ...

Toast Error not displaying

Want to pass an error toast if data is not found in the database but status response is 200.Below is what I implemented but does not show a toast ``` const searchUser=useCallback(async()=>{

const data = await supabase.from('profiles').select('name').eq('name',search)...

tRPC with part on NextJS Lambdas and part on Edge

How should I go with splitting tRPC to have some functions execute on serverless/lambdas and some on edge functions? I tried creating two separate routers with nested withTRPCs, but it didn't work.

Fetching data but getting error:null and count:null in console

Here is how i implemented it ```const [search,setSearch]=useState('') const searchUser=useCallback(async()=>{
const data = await supabase.from('profiles').select('name').eq('name',search)...