When should I not use tRPC
Hi, I'm fairly new to using tRPC, and was wondering what are some situations that would benefit to having a dedicated server to handle those tasks rather than tRPC to handle those scenarios. The only major thing I can think of is Websockets
30 Replies
not being all in on typescript
having more than 1000 endpoints
having data that is very graph shaped
having external consumers of your api
having specific performance requirements
in other words just use tRPC lol
...if you have a small-medium sized ts monorepo
adding to the list
having to send files to backend endpoints
presigned-urls go brrr
This is one of the problems I solved in my trpc like thing, and currently they're working on supporting file uploads too using multipart uploads
Anything that abuses typescript generics to the extent that trpc does will eventually reach issues with typechecking, so your tsserver will be constantly in a loading state especially if it's resolving prisma types too
If you need to actually process files on a server yourself, 1. you probably don't and 2. if you actually do you should do that on a very specific deployment lol, don't touch your damn application api with that cursed super specific bullshit
correct take
Cron jobs will need a dedicated server (or use upstash)
vercel has a service around that, even if its just calling a api route (same as upstash)
omw to check if s3 costs money
s3 costs money
fuck
but unless its heavy trafic
price is very fine
without considering caching (vercel)
$0.023 per GB (storage)
$0.09 per GB (transfering from s3 to internet)
Cost of s3 is negligible… costs pennies unless you’re throwing heaps of stuff at it
can I self host it on a esxi container with 5TB storage attached to it
i have no money or mode of payment but I have access to a friend's esxi cluster so if I can self host an s3 compatible thing
wasabi is wild
highly reccomend
its like
$0.005/gb/month
no additional fees for api calls
look at minio
How should we approach validating files? For example I want to make sure that no NSFW pictures or mostly pictures of faces are used for avatars on my website, how else can I approach it if not processing them on server? What usually developers do when someone uploads a picture of Stalin as their avatar? Do they just go with it and hope that griefers won't do it too much?
Use a service. You can’t solve this problem yourself.
Could you elaborate further? What kind of service? Btw do developers usually ignore this and let users upload anything they want? Maybe some useful articles that you have in mind on this topic? I would like to learn more about how to approach this. In my company when we ship production apps we basically ignore this altogether and use presigned URLS without any validation but I believe this is not the best/correct practice and would love to learn the correct one
Upload file to S3, trigger a lambda that check image/file content, do whatever it needs based on that
As a example
Unless you’re planning to write your own machine learning algorithm that reliably flags nsfw pictures without too many false positives (good luck on that!!!) you need to use an external service for this.
Whether or not you need to check for this type of stuff depends on the type of app
Social network? Should probably check!
Planning system for a construction company? Maybe not
Can you elaborate further, which service? Any Articles/videos on that? I will let people have public profiles that are shareable but are not really a social network
i think cloudinary offer a service like that
There’s a bunch of different companies that offer ai/ml based services for this. I’ve never used any of them so no idea how they compare.
aws has its marketplace
as a example
they have their own "nfsw" detection service kinda
Moderating content - Amazon Rekognition
Overview of inappropriate content detection in Amazon Rekognition.
Thanks