0sir1s
0sir1s
TTCTheo's Typesafe Cult
Created by 0sir1s on 8/6/2023 in #questions
How would I go about using Cloudflare R2
I'm just looking around at options, with the main 3 being uploadthing, aws s3 and cloudflare r2. R2 seems to have better pricing overall, but I'm not too sure how to go about integrating it with a ct3-app. The docs say to use amazon aws s3, but I haven't found many open source repos that use R2 in which I can have a better look at. If anyone has some experience with this could you link me to some guides maybe?
7 replies
TTCTheo's Typesafe Cult
Created by 0sir1s on 8/5/2023 in #questions
Issue with trying to build with Nextauth
So my code in auth.ts looks like this
providers: [
CredentialsProvider({
id: 'credentials',
name: 'Credentials',
// @ts-ignore
async authorize(credentials: any) {
const user = await prisma.user.findUnique({
where: { email: credentials.email },
});
if (!user) {
return null;
}
const passwordMatch = await compare(credentials.password, user.password);
if (!passwordMatch) {
return null;
}
return {
id: user.id,
name: user.name,
email: user.email,
}
},
}),
],
providers: [
CredentialsProvider({
id: 'credentials',
name: 'Credentials',
// @ts-ignore
async authorize(credentials: any) {
const user = await prisma.user.findUnique({
where: { email: credentials.email },
});
if (!user) {
return null;
}
const passwordMatch = await compare(credentials.password, user.password);
if (!passwordMatch) {
return null;
}
return {
id: user.id,
name: user.name,
email: user.email,
}
},
}),
],
and part of my code for /auth/login/index.tsx is looking like this
await signIn("credentials", {
redirect: false,
email: email,
password: password,
})
await signIn("credentials", {
redirect: false,
email: email,
password: password,
})
I am using a custom SignIn page which I think it causing issues, but upon building I get these errors:
./src/server/auth.ts
48:7 Error: Do not use "@ts-ignore" because it alters compilation errors. @typescript-eslint/ban-ts-comment
49:36 Warning: Unexpected any. Specify a different type. @typescript-eslint/no-explicit-any
51:20 Error: Unsafe assignment of an `any` value. @typescript-eslint/no-unsafe-assignment
51:27 Error: Unsafe member access .email on an `any` value. @typescript-eslint/no-unsafe-member-access
56:45 Error: Unsafe argument of type `any` assigned to a parameter of type `string`. @typescript-eslint/no-unsafe-argument
56:45 Error: Unsafe member access .password on an `any` value.
./src/server/auth.ts
48:7 Error: Do not use "@ts-ignore" because it alters compilation errors. @typescript-eslint/ban-ts-comment
49:36 Warning: Unexpected any. Specify a different type. @typescript-eslint/no-explicit-any
51:20 Error: Unsafe assignment of an `any` value. @typescript-eslint/no-unsafe-assignment
51:27 Error: Unsafe member access .email on an `any` value. @typescript-eslint/no-unsafe-member-access
56:45 Error: Unsafe argument of type `any` assigned to a parameter of type `string`. @typescript-eslint/no-unsafe-argument
56:45 Error: Unsafe member access .password on an `any` value.
12 replies
TTCTheo's Typesafe Cult
Created by 0sir1s on 7/31/2023 in #questions
tRPC mutation and data
Hi, so with tRPC I'm creating an account, which I have some checks on the function to see if an account with the same email already exists. With it, I'm returning a status code and message, and the same for if a user is successfully created. However, I am having trouble with obtaining this data on the frontend. I will either get a null/undefined object, or I will get the data but it will be from the last function call, not the current one. Currently my code looks something like this:
// frontend

mutation.mutate({
email: email,
name: username,
password: password,
});
console.log(mutation.data);
// frontend

mutation.mutate({
email: email,
name: username,
password: password,
});
console.log(mutation.data);
// backend
if (exists) {
return {
status: "409",
message: "A user with that email address already exists",
};
}

// create the user
return {
status: "201",
message: "User created successfully",
};
// backend
if (exists) {
return {
status: "409",
message: "A user with that email address already exists",
};
}

// create the user
return {
status: "201",
message: "User created successfully",
};
6 replies
TTCTheo's Typesafe Cult
Created by 0sir1s on 7/14/2023 in #questions
Understanding the t3-stack
so i'm just trying to understand the t3-stack better before I do more building with it (specifically the backend).. just want some clarification/corrections on my understanding so far nextauth - sessions/authentication for the app which can either be OAuth or email trpc - just an api kind of thing to semi-replace pages/api in nextjs that connects frontend to backend better?
39 replies
TTCTheo's Typesafe Cult
Created by 0sir1s on 7/13/2023 in #questions
How to remove default/example stuff
So I'm wondering what stuff I should be removing to have a bit more of a barebones t3 app. I've installed everything because previously I was using regular react and piecing together other packages, but now I'm just trying to have it like an all in one kind of thing I guess? However there is just a lot of boilerplate code and I'm not sure what are the core files I should be keeping, and what I can remove because it's just example files. Thanks for the help
5 replies