Juraj98
TTCTheo's Typesafe Cult
•Created by WL on 9/24/2024 in #questions
Implementation of clerk at latest version of t3-stack
What's the issue?
3 replies
TTCTheo's Typesafe Cult
•Created by Hamza Ali Turi on 8/22/2024 in #questions
Need help in TipTap
Aside from using
editor.getHTML()
you can also use editor.getJSON()
. Both of these values can be passed to content
of useEditor
. Although, if you need the HTML to later render it outside of TipTap, this might not be suitable solution for you. I guess it depends on where does the loss of html occur.
If getHTML()
returns correct HTML, but you lose some of the divs when you pass the HTML back to useEditor
, you could store both HTML and JSON. HTML for rendering, and JSON for "opening the editor again".
But if the loss of HTML happens in the output of getHTML()
, then this unfortunately won't work for you.5 replies
TTCTheo's Typesafe Cult
•Created by TwelthDd on 8/22/2024 in #questions
clerk auth default metadata
As far as I'm aware, there is no way to configure Clerk to add metadata by default for new users. There are few possible solutions that I can think of:
1. You can setup webhooks. The problem with this approach is that when user first signs up, you'll probably want to redirect them somewhere immediately. When you do that, the metadata will not be present, as it takes a while (few milliseconds, but still) for the webhook to execute. So this is probably not suitable, but I'm mentioning it, just in case you figure out how to use this method.
2. Instead of adding the metadata by default, you could add some button or even popup with "Claim free tokens" button. When users press this button, you can execute BE function to add those metadata.
3. You can leverage custom onboarding flow. This way, you can redirect users to some page (for example "/welcome") where there will be loading spinner with some text "setting up your profile" and run BE function when they visit the page. After metadata are set, you can redirect users to actual page. Let me know if you go this route, there is an issue with the code in the guide, but I have this setup in my own up, so I can provide you with workaround if needed.
4. You could reverse your counting logic. Instead of setting up certain amount of tokens and subtracting, keep track of "used free tokens". Lets say users start with 100 free tokens, if there is no metadata present, you know they have 100 free tokens left. Once they use some tokens, you just add the number to metadata and calculate remaining tokens -
const freeTokens = 100 - (metadata?.usedFreeTokens ?? 0)
7 replies
TTCTheo's Typesafe Cult
•Created by Hamza Ali Turi on 8/22/2024 in #questions
Need help in TipTap
What does "submitting the data" mean? Do you mean you're storing the data as HTML somewhere? And if so, could you try storing json instead of HTML?
Also, the column like behavior might be achievable with TipTap's official table extension. If I understand it correctly, some of the data is disappearing when you save it, then switching off of third party extension might solve the problem.
5 replies
TTCTheo's Typesafe Cult
•Created by Matthew on 7/28/2024 in #questions
ERROR: o [TRPCClientError]: Invalid response or stream interrupted
@Matt_, could I take a look at your code?
13 replies
TTCTheo's Typesafe Cult
•Created by Matthew on 7/28/2024 in #questions
ERROR: o [TRPCClientError]: Invalid response or stream interrupted
@Matt_ , are you using clerk by any chance?
13 replies
TTCTheo's Typesafe Cult
•Created by DangerZone on 6/27/2024 in #questions
Creaete T3 No Req or Res in TRPC context
@DangerZone, you're most likely importing the
getAuth
function instead of auth
function. Use the auth function, just like @Sugan_Selvam did in their screenshot. Docs8 replies
TTCTheo's Typesafe Cult
•Created by tylerlaws0n on 7/2/2024 in #questions
Has anyone had success running a Node server on Railway.app for cheap?
I double checked the sleep setting. Both projects have it off
12 replies
TTCTheo's Typesafe Cult
•Created by tylerlaws0n on 7/2/2024 in #questions
Has anyone had success running a Node server on Railway.app for cheap?
No settings for sleep. My railway configuration is all default
12 replies
TTCTheo's Typesafe Cult
•Created by tylerlaws0n on 7/2/2024 in #questions
Has anyone had success running a Node server on Railway.app for cheap?
Also, these servers are a lot more simpler than what you're doing.
12 replies
TTCTheo's Typesafe Cult
•Created by tylerlaws0n on 7/2/2024 in #questions
Has anyone had success running a Node server on Railway.app for cheap?
No they are not. But I added you to collaborators, so you can take a look. Please don't do anything bad 😄
12 replies
TTCTheo's Typesafe Cult
•Created by tylerlaws0n on 7/2/2024 in #questions
Has anyone had success running a Node server on Railway.app for cheap?
12 replies
TTCTheo's Typesafe Cult
•Created by tylerlaws0n on 7/2/2024 in #questions
Has anyone had success running a Node server on Railway.app for cheap?
Not the same use case, but I'm running two small servers through railway using bun - One is websockets, and another is HocusPocus (realtime text editing collaboration).
My memory usage is 85MB on Websockets, and 202MB on HocusPocus. My estimated cost is $2.09 for HocusPocus and $0.88 for Websockets.
Looking at your billing, it seems that most cost comes from CPU usage. You're also using
--smol
inside your start script. This argument decreases your memory usage, but increases your CPU usage. Maybe this could be a source of your high costs?12 replies
TTCTheo's Typesafe Cult
•Created by xewn on 6/23/2024 in #questions
How to send additional information with a file using UploadThing?
You can set input both on the FE component and in the filerouter middleware.
FE docs (look for
input
in the table)
BE docs2 replies
TTCTheo's Typesafe Cult
•Created by Nils on 6/23/2024 in #questions
Replacing Context with Data Access Layer
Setup can be a bit daunting, but take a look at create-t3-app. You can create empty t3 app with trpc, and just steal code from there. Or go other way, and copy your code into t3 app.
10 replies
TTCTheo's Typesafe Cult
•Created by Nils on 6/23/2024 in #questions
Replacing Context with Data Access Layer
Yes. I'm currently using supabase for my db with trpc. Trpc is just a very handy way to define your communication between FE and BE. You write your BE functions(procedures) and it automatically infers all the types for api function you call on FE.
10 replies
TTCTheo's Typesafe Cult
•Created by Nils on 6/23/2024 in #questions
Replacing Context with Data Access Layer
Also, please take a look at trpc if you haven't already. It could simplify a lot of what you're doing.
10 replies
TTCTheo's Typesafe Cult
•Created by Nils on 6/23/2024 in #questions
Replacing Context with Data Access Layer
Hey Nils. There are multiple multiple ways to solve this.
First of all, even if you want to do as much on server as possible, there is nothing wrong with handling some of the data client side. But there are other options.
1. Put the team id into the url. So the url would be like
/[activeTeam]/home
. I tried to open the app so I can see what's exactly is going on, but there are some errors and I can't actually create team. But if /home
is same on every url, you can still render the same component on every /[activeTeam]/home
.
2. Save last visited team for each user to db. This way you can call some server action like getLastVisitedTeam
and you'll get the data you need. And when user switches the team using the dropdown, you can save the new team using something like visitTeam
. I don't know if this is a right approach for you tho, because it seems like the team selection affects a lot of content.10 replies
TTCTheo's Typesafe Cult
•Created by Maastonakki on 6/21/2024 in #questions
How T3Stack env.js actually works?
This is not black magic of
createEnv
, but a black magic of Next. Next automatically looks for .env
file and loads the contents of that file into process.env
. When you're running tsx seed.ts
, this file is not loaded. You can use packages such as dotenv or dotenv-cli to load contents of the .env
file when using tsx
.6 replies
TTCTheo's Typesafe Cult
•Created by Muhct on 6/20/2024 in #questions
Best practices for typing a reusable button?
+1 for @Matvey's solution of extending
ComponentProps
.
I'd also like to argue, that generally, have as much of the props optional as possible. If I take component made by someone else, most of the time the first thing I want to do is render it, to see how it behaves "by default" and what happens when I start to add additional props.
In this case it doesn't matter that much, because everyone generally understands what children
do, but I'd still have it optional as a rule of thumb. And of course, this is my personal preference, do it or don't based on how it feels to you.
Another thing I'd change is leftIcon
to ReactNode
, instead of ReactElement<SVGSVGElement>
. That way you can pass something that's not a svg. (For example loading spinner component).6 replies