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

[possiblo?] i made this garbage code, can you make it better

https://github.com/barrybtw/aktiesparekonto/blob/master/lib/calculate.ts just lets me know how much money i'd have after x years, how much is profit, how much will be paid in tax, the code is ugly as hell but i dont think it can get better, but maybe someone in here is the einstein of coding and maths...

Stale dynamic sitemap

I am trying to create dynamic sitemap but after first time it is not updating the sitemap can anyone help me fix this issue? code:-https://github.com/pradeep800/striver-sheet-webiste/blob/main/app/sitemap.ts...

Prevent malware upload to uploadthing/s3 bucket

Hey all, I need to allow file uploads for authenticated users which would then be read by my employees in aid of our medical services. I want to have all my bases covered with security esp in light of the recent LTT attack. How would you protect your s3/uploadthing bucket from malware, trojans etc.
Solution:
Nyx is probably right that it would not hurt to post this in #uploadthing, but afaik this is not a feature built into upload thing. One thing you could do it setup a node server that checks files and then writes them to S3 / Upload Thing. Depending on your file size / quantity though, this may need to be a actual node server running on something like https://railway.app as payload size and runtime are limited on serverless. Alternatively, you could upload files and then run checks later marking it in your DB or something which would make it so that when people upload stuff it does not take a long time scanning it (though the stuff about the node server still applies). This library seems like it would work well for your use case. Obviously no lib is foolproof but this one does look relatively solid. ...

Can anyone suggest a good library for PostgreSQL similar to Mongoose?

I am learning PostgreSQL with Express. Can anyone suggest a good library for PostgreSQL similar to Mongoose?

Type Errors When Using File Input w/ react-hook-form & shadcn/ui

Hello! I was wondering if anyone has an example of them using react-hook-form and shadcn/ui for a file upload. I have been attempting to add this to a <Form /> but I am running into various type errors. I made a issue which goes a little more into depth about the issues I am running into: https://github.com/shadcn-ui/ui/issues/1085 Thanks for the help!...

How do you handle global state with RSCs?

Hi Im having a hard time to understand how you can leverage RSCs for data fetching if the data you want to fetch is dependent on user input. Case Example...

csv uploads

Trying to upload a csv file with UploadThing and keep running into this error, should it be a different file type? ``` export const ourFileRouter = { // Define as many FileRoutes as you like, each with a unique routeSlug...

Weird auth.js type behaviour with custom providers

I made a custom magic link email login provider for auth.js and it all works fine and dandy with no type errors to be seen; however, as soon as do a full app typecheck, while ignoring node modules on sveltekit, somehow the auth.js library types feelsverysadmanwowcry has anyone else ran to a similar issue? There is nothing inherently wrong with my ts config and my custom provider abides to the auth.js types for providers too.

Any good open source projects build with t3 stack?

I come from Laravel, RoR where things are mostly opinionated but comfortable. But when you start building stuff with something where you need to glue everything together yourself, you get stuck - a lot. So I'm looking for good open source projects to draw inspiration from.

Redux reducer type error

Why does this give me an error, its mostlikely because of how I did the typing.
Type 'ImageCreatorElement[]' is not assignable to type '(WritableDraft<{ type: ImageCreatorElementType; id: string; layer: string; x: number; y: number; isDragging: boolean; isSelected: boolean; metadata?: Record<string, string> | undefined; } & ImageCreatorImageElement> | WritableDraft<...>)[]'.
Type 'ImageCreatorElement[]' is not assignable to type '(WritableDraft<{ type: ImageCreatorElementType; id: string; layer: string; x: number; y: number; isDragging: boolean; isSelected: boolean; metadata?: Record<string, string> | undefined; } & ImageCreatorImageElement> | WritableDraft<...>)[]'.
...

Rate Limiting in AWS API Gateway

Hello! I need to implement rate limiting for some of my API Gateway endpoints that have lambda proxy integrations. As a result of the proxy integrations, and because I would like to include a "Retry-After" header, I need to include the rate limiting logic in my lambda itself - I can't do it on the API gateway level. Currently I am thinking of selecting the count of requests from the client in the last 60 seconds from my database and applying rate-limiting based on that. ...

CommonJS/Module Errors Feel Random?

Hey! I have two projects with an identical configuration. For some reason, one project will run while the other one will fail due to an ES Module error. package.json and tsconfig.json of project that works: ```json package.json...

How to connect uploadthing to the Clerk auth?

I am using the pages directory and want to protect my file upload using Clerk's getAuth. I get the following error: ERROR! An error occured when running the middleware for the imageUploader route
Solution:
I think I had the same problem as you and used https://github.com/matthewspear/uploadthing-clerk-app to fix it

NextJS CLI script

How do I go about running a script as a "CLI" script in my NextJS project? I've tried https://dev.to/philippe/create-a-cli-script-in-your-nextjs-project-2pg2 but it looks like I can't "import" using that (module does not export...)
Solution:
Create a .ts file anywhere in your src dir and use https://github.com/egoist/tsno to run it

Has anyone found a good collection of prebuilt, general-use components using nativewind?

Something like tailwind-ui with mobil in mind would be fantastic!

Setting up and testing endpoints (for t3 stack)

Hey y'all. Fairly new to this tech stack (and next.js in general) so forgive the potential ignorance of the question, but i haven't seemed to find any clear answers on this (or i just know too little). Anywhos, the thing i'm wondering is can i define/test "traditional" endpoints using the api/routers way, and how does that work? Eg. i would like to create a getUserById get endpoint, and a createUser endpoint, and then try calling them externally (e.g. via postman, or another website, etc.) How do you go about doing this?...

Prisma or Trpc for fetching data?

Hello! I see that in NextJS 13 i can use prisma directly in my components to get the data. Is there an advantage using TRPC instead and using prisma in the Trpc server instead?

Prisma enum causes maximum call stack size exceeded.

queryType on operation model is causing stack overflow when 'prisma generate' or 'prisma db push'. So soon as I remove it and replace data type to something like String, everything's okay. How do I fix this if not get rid of this enum?...
Solution:
Okay, It was fixed in 5.1.0, apparently.

Help me not to give up on t3.

I've been trying to implement optimistic updates on my app but i'm getting a lot of errors. I started by following the react query docs and tried implementing it like this ```javascript...

eslint

I am failing to see a repository using the following: ```config 'plugin:@typescript-eslint/recommended-type-checked', 'plugin:@typescript-eslint/stylistic-type-checked',...