Paul
Paul
Explore posts from servers
TTCTheo's Typesafe Cult
Created by rcssdy on 10/1/2023 in #questions
Undici error (Drizzle + Next.js 13.5)
Without reading into any documentation, I don’t think you need the fetch variable when connecting? If you do, try using the native fetch and see if it works to break down what the issue might be
4 replies
TTCTheo's Typesafe Cult
Created by SharpieMaster on 9/25/2023 in #questions
t3 app router when?
Also I want to take my statement back a bit. Server actions won’t kill trpc. But server actions really feels like a response to trpc and you can achieve many of the same things using server actions and fetch as opposed to trpc. So trpc is still fine. Keep using it if it works. But to me, it feels like server actions is the response to smth like trpc. Also for anyone reading this: server actions is still experimental and has issues like flashing of unstyled content so I’m not saying we should adopt it now. But just that the future looks like server actions will be more of the default choice vs trpc. Again, I’d avoid using server actions right now cuz it’s still buggy.
24 replies
TTCTheo's Typesafe Cult
Created by SharpieMaster on 9/25/2023 in #questions
t3 app router when?
I’ve encountered a similar issue. Personally I would say be okay with rewriting your code. I used to think similarly to always want to futureproof but new things keep popping up and I keep getting outdated. I’d say just keep using what you’re familiar with and what you have working in your code. Then on your spare time learn the new things as it oftentimes helps you get a deeper understanding of how what you’re currently using works. The difference between trpc and server actions and routes isn’t that much different per say, you can always port stuff over. Overall I’d say keep doing what works and on your spare time you can dabble and learn. For me personally, I used typical routes but it seems so clunky and slow and then I tried trpc but app router came out and I dropped it and when I tried to rewrite it I got it working but not for server calls and didn’t want to rewrite my backend to trpc and kinda gave up. Then lately I dove in server actions and it seems good but it keeps having issues with flashing of unstyled content. So now I’m back to using react query and GET/POST routes in the app router. tl;dr just use what works and keep moving forward imo. Rewrites imo are kinda inevitable esp as you learn more things and new things keep popping up. One day you may switch your backend over to rust, so yeah just keep building and learning as you go and be okay with rewrites in the future
24 replies
TTCTheo's Typesafe Cult
Created by Paul on 9/29/2023 in #questions
Server Actions: Do you need to validate the session when calling Server Actions?
I think I've come to realize... you still need to validate the session when using server actions that mutate data since determined hackers can still manipulate the frontend javascript. However, in terms of csrf-tokens, is that still needed? And if so, can someone explain how it should be implemented? Does it make sense to call a server action to get a csrf-token and maybe save it in a database and then when calling a mutation-like server action, return that same csrf token? I'm unclear on the higher-level rationale behind doing so, given that I'm not sure if a hacker can do the same cross-site scripting attacks anymore with server actions
3 replies
TTCTheo's Typesafe Cult
Created by max14 on 9/27/2023 in #questions
ShadCn Styling / Functionality Issue
Look at the example in the playground on shadcn for the dropdown. https://ui.shadcn.com/examples/playground You want to use a popover and not a tooltip. Look at the code here. https://github.com/shadcn-ui/ui/blob/main/apps/www/app/examples/playground/components/model-selector.tsx
22 replies
TTCTheo's Typesafe Cult
Created by SharpieMaster on 9/25/2023 in #questions
t3 app router when?
The more I think about it, the more I think server actions is pretty much gonna kill trpc. - server actions allows you to have type safety front and back. - server actions can have loading state with the latest experimental useFormStatus - server actions can have onSuccess and onError that you manually return from the server action via the experimental useFormStatus hook via the data you receive back from the server action - In terms of middleware to validate sessions, you write a general server action to wrap another mutating server action All in all... after trying to figure all that trpc stuff with the app router myself and not getting it to work on the server. IMO there's a reason why this is taking so long and the hype is dying around it a bit. Cuz as I mentioned, when you get deeper into server actions, you realize you don't really need trpc imo Edit: for anyone reading this, i wouldnt use server actions yet (sep 30 2023) cuz it’s still experimental and buggy namely with flashing of unstyled content. But just noting for the future of trpc vs server actions
24 replies
TTCTheo's Typesafe Cult
Created by Typedef on 9/20/2023 in #questions
Selecting through transparent background KonvaJS
I asked chatgpt a lot and I think @lukem121's solution is best. Maybe something like when holding control and hovering over an element, apply pointer-events:none to the top layers so the bottom layer can detect the click. Otherwise, the top layer can't detect the click apparently. And chatgpt suggests using a ref to determine if a click target matches the underlying element via a ref if you think that's appropriate.
if (event.target === this.topmostElementRef.current) {
console.log('Clicked on the topmost element.');
} else if (event.target === this.underlyingElementRef.current) {
console.log('Clicked on the underlying element.');
}
if (event.target === this.topmostElementRef.current) {
console.log('Clicked on the topmost element.');
} else if (event.target === this.underlyingElementRef.current) {
console.log('Clicked on the underlying element.');
}
I was thinking about the click event bubbling up, but I'm not sure that applies in this case since the layers aren't parents of other layers
4 replies
TTCTheo's Typesafe Cult
Created by Will on 9/23/2023 in #questions
What happens if I accidentally use `npm install` inside of a turborepo using `pnpm`?
To my understanding, npm saves files locally in each workspace, while pnpm hoists it to the main node_modules as it deems appropriate. It will still work. If you want to be sure, just delete node_modules in each of your workspaces and do pnpm install again
3 replies
TTCTheo's Typesafe Cult
Created by Paul on 4/20/2023 in #questions
next13 app dir - multiple route handlers in one folder?
For pages I personally like that structure as it’s quite organized. For routes… my initial thought is to want to put a few on one page like many other frameworks allow for…
7 replies
TTCTheo's Typesafe Cult
Created by Paul on 4/20/2023 in #questions
next13 app dir - multiple route handlers in one folder?
That is… each folder has it’s own route.ts file to denote a separate route. As opposed to smth like… doThis.route.ts and doThat.route.ts all in one folder
7 replies
TTCTheo's Typesafe Cult
Created by Paul on 4/7/2023 in #questions
How to connect planetscale database using pgAdmin?
Oh.... I was wondering why there wasn't an option on planetscale to choose between postgres vs mySQL. Thanks.
4 replies
TTCTheo's Typesafe Cult
Created by Paul on 3/10/2023 in #questions
Database structure for contacts in a CRM?
This is very helpful. Thanks a lot!
3 replies
TTCTheo's Typesafe Cult
Created by Paul on 3/4/2023 in #questions
Tree Shaking with Good DX
Also, if in my application I use Table.Header once, does that mean it'll be included in the bundle so there's no point trying to remove tree-shake it because all other references will just be a reference to it? So the only benefit of tree-shaking is when you DON'T use it at all anywhere in your application?
2 replies
TTCTheo's Typesafe Cult
Created by Paul on 1/9/2023 in #questions
trpc - Calling a route inside itself
Thanks!
3 replies
TTCTheo's Typesafe Cult
Created by Paul on 10/18/2022 in #questions
[Solved] Why does leetcode say “non-decreasing” and not “ascending”
That makes sense and is very clear. Thank you
6 replies
TTCTheo's Typesafe Cult
Created by Paul on 10/18/2022 in #questions
[Solved] Why does leetcode say “non-decreasing” and not “ascending”
I guess I mean to ask… if non-decreasing means something technically different than ascending. Or is it just somehow easier to comprehend?
6 replies