Alky
Alky
TTCTheo's Typesafe Cult
Created by dylancam812 on 2/4/2024 in #questions
PlanetScale vs Turso
Turso uses a fork of SQLite(libSQL), and aims to make distributed databases. Planetscale uses MySQL and aims to provide a zero-downtime experience with MySQL. They're really different, so choose what concept suits you best.
6 replies
TTCTheo's Typesafe Cult
Created by nico on 2/1/2024 in #questions
Integrating Clerk: How to supply req to createTRPCContext on server-side?
On the app router section of Clerk docs, it doesn't need the Request to be passed in. See here
6 replies
TTCTheo's Typesafe Cult
Created by chawnsphone on 2/1/2024 in #questions
Prisma queries return type any
Me too. In my case the TS server was working, but the ESLint was throwing "as any" everywhere in my code. I ended up disabling a lot of rules(that i usually use) and i could work in peace. Today i got back to the project, enabled all the rules and the error wasn't there anymore. I have no idea what is causing the issue. I also tried create-t3-app today the same way as the issue, and the error was not there.
21 replies
TTCTheo's Typesafe Cult
Created by NoelHuibers on 2/1/2024 in #questions
Drizzle Planetscale "text" in schema (MySQL) "Key specification without key length"
I don't think there's a problem in your code. The error points toward a column named "details", so maybe is somewhere else. Another thing to keep in mind is that to index a Text type, your database needs to use the InnoDB or MyISAM engines.
6 replies
TTCTheo's Typesafe Cult
Created by YUCCIE on 1/23/2024 in #questions
Change File Name Automatically
Yeah, of course.
export const FileUpload = ({
onChange,
endpoint
}: FileUploadProps) => {
return (
<UploadDropzone
endpoint={endpoint}
onClientUploadComplete={(res) => {
onChange({url:res?.[0].url, fileName:res?.[0].fileName});
}}
onUploadError={(error: Error) => {
toast.error(`${error?.message}`);
}}
/>
);
}
export const FileUpload = ({
onChange,
endpoint
}: FileUploadProps) => {
return (
<UploadDropzone
endpoint={endpoint}
onClientUploadComplete={(res) => {
onChange({url:res?.[0].url, fileName:res?.[0].fileName});
}}
onUploadError={(error: Error) => {
toast.error(`${error?.message}`);
}}
/>
);
}
<FileUpload
endpoint="courseAttachment"
onChange={(e:{url:string, fileName:string}) => {
if (e.url) {
onSubmit({ url: e.url, fileName:e.fileName});
}
}}
/>
<FileUpload
endpoint="courseAttachment"
onChange={(e:{url:string, fileName:string}) => {
if (e.url) {
onSubmit({ url: e.url, fileName:e.fileName});
}
}}
/>
You would need to change your interfaces accordingly. e.g:
interface FileUploadProps {
onChange: (e: {url?:string, fileName:string}) => void;
endpoint: keyof typeof ourFileRouter;
};
interface FileUploadProps {
onChange: (e: {url?:string, fileName:string}) => void;
endpoint: keyof typeof ourFileRouter;
};
Then, i'm guessing the onSubmit is the function that pass those argumentos to your API, right? Change it to receive not only the URL, but also the fileName, and pass it as the "name" field in your db
24 replies
TTCTheo's Typesafe Cult
Created by Mike Pollard on 1/23/2024 in #questions
Is the backend of this stack a lambdalith (lambda monolith) when hosted serverless?
It doesn't really makes any difference. Having one or multiple API endpoints will consume the same lambda resources: the number of calls. In terms of processing power, it's not going to interfere one with another by the concept of the serverless functions. Every API call creates a new instance of the Serverless function(lambda), behavior which will be the same for one or multiple endpoints. But talking about independently scale, this would be useful if you wanna provide more availability to one group of endpoint more than others. In this case, i guess you could just limit or control in some other way the number of calls this group of endpoints provides. I mean, as far as i know, this separation would only make sense to see the "details" under the AWS Lambda dashboard, but you could get kinda of the same result tracking the api call at /api/trpc/, since the Path are always different for each one, despite being just one lambda.
6 replies
TTCTheo's Typesafe Cult
Created by Luc Ledo on 1/30/2024 in #questions
Best way to get a react component's raw code?
The way shadcn does it's not really on his repo. The only thing you can learn is here and here. He uses a lot of plugins and something called "contentlayer", which is under all gitignores. And based on those files, he really parses it in a way that the "<ComponentPreview />" receives just a name prop, and the search for the doc e in which contains the "doc.body.code" property, which is generated in build time, i assume. If you wanna do something similar, maybe wrap your components inside some specific comment "tags", then create a script that read the some folders file and grab(if exists) just the content inside the specified tags and then make it available for your project in some kind o way, like an object indexed by name. Anyway, i don't think is gonna be any fast work
13 replies
TTCTheo's Typesafe Cult
Created by YUCCIE on 1/23/2024 in #questions
Change File Name Automatically
The easiest way is to just pass the Name of the file to your db on the same callback you use to save it in your db. I believe that "onSubmit" saves it to your db, right? Instead of receiving just the URL, send the fileName together. At your OnClientUploadComplete, send the URL and also the FileName, since it's available. Then propagate it to your onSubmit and save it to your DB
24 replies
TTCTheo's Typesafe Cult
Created by YUCCIE on 1/23/2024 in #questions
Change File Name Automatically
So you want to save the correct name into your db, or you doesnt want to have to save the name at all? If it's the first one, you can just use the download callback to save it. If it's the second case, you can read the file from the URL provided by your db and then get the name from the metadata
24 replies
TTCTheo's Typesafe Cult
Created by YUCCIE on 1/23/2024 in #questions
Change File Name Automatically
Oh, got it. The attachments array comes from your DB?
24 replies
TTCTheo's Typesafe Cult
Created by Trader Launchpad on 1/29/2024 in #questions
Difference between NextAuth + firebase adapter, NextAuth + drizzle adapter, and just using firebase?
I don't really understand why would you want to have the user authenticated in both your app and on firebase. Wouldn't just one be enough?
6 replies
TTCTheo's Typesafe Cult
Created by Clemens on 1/29/2024 in #questions
Setting queryHash with t3 useQuery good practice?
You could do ["router.getTotalPosts", { from, to: 1}]. I think it's easier to make the to query param constant instead of making a queryHashFn that would discard it. Anyway, i guess the problem with definig the queryHash would be in the case you define two or more different endpoints with the same queryHash. Besisdes than that, it would only revalidate based on the revalidate param. If the query is revalidated at 11:59pm, it will not refresh at 00:00am, even with from changing. I think that my first suggestions achieves what you want
7 replies
TTCTheo's Typesafe Cult
Created by Trader Launchpad on 1/29/2024 in #questions
Difference between NextAuth + firebase adapter, NextAuth + drizzle adapter, and just using firebase?
The best route depends on what you wanna own. I'm kinda bias here because i don't really like to use NextAuth, but the first two case scenarios you give up parts of the App Auth Logic to NextAuth, and keep the database records. In your mobile app, you'll have or to mimic the NextAuth to keep the database tables the same, or create another logic creating more tables. The third one you give up all the logic to firebase. The advantage here i think is that on the mobile app you can just use the firebase mobile version(if it exists, i don't really know) and don't worry about compatibility or modifying anything. The best routes depends on what you wanna depend , what you're willing to do compatibility wise, and how important these steps are for you project. Between these 3, i would go with the NextAuth + Drizzle, since it seems to me it's the one you would have more control of. But considering that you will make a Mobile App, isn't it better if you own auth logic and use the same one across services?
6 replies
TTCTheo's Typesafe Cult
Created by YUCCIE on 1/23/2024 in #questions
Change File Name Automatically
The file name is kept, the URL uses the fileKey. but if you try do download it, you'll download the file with the proper name
24 replies
TTCTheo's Typesafe Cult
Created by YUCCIE on 1/23/2024 in #questions
Change File Name Automatically
No description
24 replies
TTCTheo's Typesafe Cult
Created by arete on 4/8/2023 in #questions
handle onError mutation
Try setting retry: false on the query level and see if it works. If it works, you probably have to change your default query client configs.
15 replies
TTCTheo's Typesafe Cult
Created by arete on 4/8/2023 in #questions
handle onError mutation
This way, the error is never thrown. If instead of retry:true you have retry:5, with e.g retryDelay:2000, it will take 10 seconds( 5 * 2000ms) + 10 error executions before the error is thrown. If retry:true, the error will never be thrown, because it will keep trying.
15 replies
TTCTheo's Typesafe Cult
Created by arete on 4/8/2023 in #questions
handle onError mutation
No description
15 replies
TTCTheo's Typesafe Cult
Created by arete on 4/8/2023 in #questions
handle onError mutation
No description
15 replies
TTCTheo's Typesafe Cult
Created by arete on 4/8/2023 in #questions
handle onError mutation
Can you show how you're returning error on API side?
15 replies