JulieCezar
JulieCezar
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Joji on 11/17/2024 in #questions
does nextAuth provide phone otp authentication?
You could theoretically build an auth layer yourself, then maybe use twilio or something similar. This might give you a bit cheaper solution, but given the time you will invest, the potential problems, and lack of features compared to auth providers, I don't think this is a viableoption
4 replies
TTCTheo's Typesafe Cult
Created by Joji on 11/17/2024 in #questions
does nextAuth provide phone otp authentication?
I don't know if there are auth providers for phones exclusively, meaning you have to go with some of the current auth solutions... Clerk is the cheapest IMO. From others I know firebase has it, Auth0... there are sure others but I havent used them... If you want to go self host maybe try Appwrite, however you still need a way to send SMSs, which means you need to use a provider like Twilio or something like that which is quite expensive... so again we are back to clerk
4 replies
TTCTheo's Typesafe Cult
Created by sogzyy on 8/31/2024 in #questions
Convert to webp before upload
and you can use something like sharp for that https://www.npmjs.com/package/sharp
12 replies
TTCTheo's Typesafe Cult
Created by sogzyy on 8/31/2024 in #questions
Convert to webp before upload
usually though, it's not really common to do such things on the client, but to just upload to the server, maybe check mime types before, then on the server optimize and/or convert to webp
12 replies
TTCTheo's Typesafe Cult
Created by sogzyy on 8/31/2024 in #questions
Convert to webp before upload
However, if you decide to stay with what you have... then i guess you would have to intercept the POST request before it's made, then do all the type checks as well as convert to webp then continue with POST
12 replies
TTCTheo's Typesafe Cult
Created by sogzyy on 8/31/2024 in #questions
Convert to webp before upload
+ you get a nice UI for uploading
12 replies
TTCTheo's Typesafe Cult
Created by sogzyy on 8/31/2024 in #questions
Convert to webp before upload
If you are uploading through forms and want to check types, resize etc. on the client, look into Uppy Uploader... It has all those feature and more, and you can upload to w/e you like
12 replies
TTCTheo's Typesafe Cult
Created by Brave Traveller on 10/23/2024 in #questions
One line param checking question
function funcA(){
if(funcB()) return
}
function funcA(){
if(funcB()) return
}
you mean this? but continuing on you idea, I would create a generic function that takes in the URL and a zod schema... then use JS method with zod to validate if all is good. Something like:
function ValidateParams(url: string, schema) {
const _url = new URL(url);
const paramsIterator = new URLSearchParams(_url.search.slice(1));
const params = {};

for (const [key, value] of paramsIterator) {
params[key] = value;
}

const parseResult = schema.safeParse(params);

// or return w/e you want
if (parseResult.success === true) {
return {
success: parseResult.success,
data: parseResult.data,
};
} else {
return {
success: false,
error: parseResult.error,
};
}
}

// or with TS
function ValidateParams<T extends z.ZodSchema>(
url: string,
schema: T
): z.SafeParseReturnType<z.infer<T>, z.infer<T>> {
const _url = new URL(url);
const paramsIterator = new URLSearchParams(_url.search.slice(1));
const params: Record<string, string> = {};

for (const [key, value] of paramsIterator) {
params[key] = value;
}

const parseResult = schema.safeParse(params);

// or return w/e you want
if (parseResult.success === true) {
return {
success: true,
data: parseResult.data,
};
} else {
return {
success: false,
error: parseResult.error,
};
}
}
function ValidateParams(url: string, schema) {
const _url = new URL(url);
const paramsIterator = new URLSearchParams(_url.search.slice(1));
const params = {};

for (const [key, value] of paramsIterator) {
params[key] = value;
}

const parseResult = schema.safeParse(params);

// or return w/e you want
if (parseResult.success === true) {
return {
success: parseResult.success,
data: parseResult.data,
};
} else {
return {
success: false,
error: parseResult.error,
};
}
}

// or with TS
function ValidateParams<T extends z.ZodSchema>(
url: string,
schema: T
): z.SafeParseReturnType<z.infer<T>, z.infer<T>> {
const _url = new URL(url);
const paramsIterator = new URLSearchParams(_url.search.slice(1));
const params: Record<string, string> = {};

for (const [key, value] of paramsIterator) {
params[key] = value;
}

const parseResult = schema.safeParse(params);

// or return w/e you want
if (parseResult.success === true) {
return {
success: true,
data: parseResult.data,
};
} else {
return {
success: false,
error: parseResult.error,
};
}
}
and then you have something like:
import { z } from "zod";

const mySchema = z.object({
id: z.number(),
name: z.string(),
});

if(ValidateParams("https://.....", mySchema).success === false) return
import { z } from "zod";

const mySchema = z.object({
id: z.number(),
name: z.string(),
});

if(ValidateParams("https://.....", mySchema).success === false) return
Although this might be a bit better since you will probably reuse the params:
import { z } from "zod";

const mySchema = z.object({
id: z.number(),
name: z.string(),
});

const result = ValidateParams("https://.....", mySchema)

if(result.success === false) return

console.log(result.data)
import { z } from "zod";

const mySchema = z.object({
id: z.number(),
name: z.string(),
});

const result = ValidateParams("https://.....", mySchema)

if(result.success === false) return

console.log(result.data)
3 replies
TTCTheo's Typesafe Cult
Created by Julien Castets on 10/22/2024 in #questions
Flowbite vs tailwind UI vs shacdn vs ??
I think that flowbite uses only Tailwind classes not any of special ones, despite what I said before, but I'm not sure... Still everything else is on point ✅
16 replies
TTCTheo's Typesafe Cult
Created by Julien Castets on 10/22/2024 in #questions
Flowbite vs tailwind UI vs shacdn vs ??
Flowbite is not extensible like that, it comes with predefined class names alongside standard Tailwind classes, or actual Components if you use it with some framework (e.g. react) However, you DO NOT own the code, you get the code bundled into your modules and can use it, but you CANT change it - the only way to change the style and behavior is through props. In that sense flowbite is a component library like MUI for example. ShadCn works completely different from that, when you run the command to install a component, they put an actual .tsx file into your code that has exports that component (e.g. Button).
Now you can use that normally like any other component, but the magic is that YOU OWN the source code for the component. You can change any behaviour you want inside it, add variants etc. Also, it uses only tailwindcss classes for styling so you don't need to learn anything else. While flowbite allows you to copy-paste the code, (at least for the frameworks) it still requires you to install the actuall library with the components inside. Also, Shadcn uses RadixUI under the hood for better accessibility and usability... idk if flowbite does that for you. TLDR; shadcn is the most extensible UI library, it defined a whole new perspective on UI libraries and is quickly becoming the standard solution because of it's versatility. Some potential drawbacks are that most UI libraries have more styles, components etc. and flowbite can be used with multiple languages, while Shadcn is mostly for React, Solid and Vue. But for the first point, you can just find tailwind code for a button you like, paste it into the generated shad component and you are good to go 💪 My recommendation - go with shadcn
16 replies
TTCTheo's Typesafe Cult
Created by JulieCezar on 9/11/2024 in #questions
Is it possible to revalidate path after a useMutation call?
Video of the problem
3 replies
TTCTheo's Typesafe Cult
Created by JulieCezar on 8/30/2024 in #questions
App crashes when TRPC error is thrown on the server
No description
4 replies
TTCTheo's Typesafe Cult
Created by Salumsu on 7/30/2024 in #questions
T3 App type error
Idk if you are using the t3 template... If not, if you set it up through the CLI you will see a working solution
27 replies
TTCTheo's Typesafe Cult
Created by JustCodeItAll on 7/24/2024 in #questions
where is signup with email and password option at?
Never heard of it. But looking at now it it's probably not for me. Installing all of the packages they help you install doesn't take that much time tbh. And if I did use it, I would have to check if everything is setup as I would want... I would have to be checking if Kirimase is up to date with the latest versions of those packages... And with all that you would probably still have to go to the actual packages docs to read about them... So I like to keep the things I use more under my control... I might be wrong though, I would have to actually try it.
7 replies
TTCTheo's Typesafe Cult
Created by D4rzk on 7/16/2024 in #questions
Uploadthing and S3
AWS starts off as cheap because of their generous free tier. However, when you start having more data/more traffic it spikes exponentially. This is mostly due to bandwidth. UploadThing makes you not think about bandwidth. You pay 10$, you get 200GB or w/e it is, and that's it. Regarding the AWS 50$ cost, it's incorrect. With this little traffic and storage, the free tier will cover most of it. Using the AWS calculator with the numbers chatgpt gave you I got an estimated 1$/month. Check out https://calculator.aws/#/createCalculator/S3
5 replies
TTCTheo's Typesafe Cult
Created by johnny the fifth on 7/19/2024 in #questions
which method is better for authentication
Or Next-Auth, they have better docs imo
6 replies
TTCTheo's Typesafe Cult
Created by johnny the fifth on 7/19/2024 in #questions
which method is better for authentication
If you don't want to do all that work, use Clerk
6 replies
TTCTheo's Typesafe Cult
Created by TEJAS on 7/23/2024 in #questions
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
If you got this message, going from TSX to JSX wont help, on the contrary it might get you more problems. Also, I don't know what made you try this but please don't ever do that again 🤣 Firstly, try to delete node_modules, reinstall all deps, and try to build locally. Also, I need more info... like is this specific to AWS? Can you build locally? What are you using to deploy to AWS?...
3 replies
TTCTheo's Typesafe Cult
Created by JustCodeItAll on 7/24/2024 in #questions
where is signup with email and password option at?
Also read their docs, you will find everything
7 replies