oferitz
oferitz
CCConvex Community
Created by tiernacity on 2/21/2024 in #support-community
Problem integrating react-email into an internal action
@Michal Srb Thanks, appreciate the effort to help, but I have fully moved to a solution where Convex is sending an API request to my Next.js backend (https://discord.com/channels/1019350475847499849/1019350478817079338/1214518908623654972), which handles the actual email sending. This also eliminates the CSS files limitation mentioned above.
42 replies
CCConvex Community
Created by tiernacity on 2/21/2024 in #support-community
Problem integrating react-email into an internal action
@Michal Srb Same with running tsc
42 replies
CCConvex Community
Created by tiernacity on 2/21/2024 in #support-community
Problem integrating react-email into an internal action
I haven't tried yet. I'll need to set up everything again since I moved to a workaround involving Convex calling a Next.js API route to handle the sending.
42 replies
CCConvex Community
Created by tiernacity on 2/21/2024 in #support-community
Problem integrating react-email into an internal action
You mean running tsc?
42 replies
CCConvex Community
Created by tiernacity on 2/21/2024 in #support-community
Problem integrating react-email into an internal action
@Michal Srb 1. convex/utils.ts 2.
export const authMutation = customMutation(
mutation,
customCtx(async (ctx) => ({ user: await getUserOrThrow(ctx) }))
)

async function getUserOrThrow(ctx: QueryCtx | MutationCtx) {
const userId = await getUserId(ctx)

if (!userId) {
throw new ConvexError('must be logged in')
}

const user = await ctx.db
.query('users')
.withIndex('by_userId', (q) => q.eq('userId', userId))
.first()

if (!user) {
throw new ConvexError('user not found')
}

return user
}
export const authMutation = customMutation(
mutation,
customCtx(async (ctx) => ({ user: await getUserOrThrow(ctx) }))
)

async function getUserOrThrow(ctx: QueryCtx | MutationCtx) {
const userId = await getUserId(ctx)

if (!userId) {
throw new ConvexError('must be logged in')
}

const user = await ctx.db
.query('users')
.withIndex('by_userId', (q) => q.eq('userId', userId))
.first()

if (!user) {
throw new ConvexError('user not found')
}

return user
}
42 replies
CCConvex Community
Created by tiernacity on 2/21/2024 in #support-community
Problem integrating react-email into an internal action
@ballingt I'm revisiting the issue because I'm still struggling to make this work. I have followed this post and another one at https://discord.com/channels/1019350475847499849/1161498699558559754. Additionally, I have set up a simple example similar to the one you linked from GitHub. I have created my own tsconfig.json in the convex folder, just like in your example. It seems to do the trick regarding building TSX files, but now I am encountering TypeScript errors in my function. For example, in this function:
export const createTemplate = authMutation({
args: {
name: v.string(),
},
handler: async ({ db, user }, args) => {
const { name } = args
return await db.insert('templates', {
userId: user._id,
name
})
}
})
export const createTemplate = authMutation({
args: {
name: v.string(),
},
handler: async ({ db, user }, args) => {
const { name } = args
return await db.insert('templates', {
userId: user._id,
name
})
}
})
I Get:
convex/templates.ts:54:21 - error TS7031: Binding element 'db' implicitly has an 'any' type.

handler: async ({ db, user }, args) => {


convex/templates.ts:54:25 - error TS7031: Binding element 'user' implicitly has an 'any' type.

54 handler: async ({ db, user }, args) => {

convex/templates.ts:54:33 - error TS7006: Parameter 'args' implicitly has an 'any' type.
I Get:
convex/templates.ts:54:21 - error TS7031: Binding element 'db' implicitly has an 'any' type.

handler: async ({ db, user }, args) => {


convex/templates.ts:54:25 - error TS7031: Binding element 'user' implicitly has an 'any' type.

54 handler: async ({ db, user }, args) => {

convex/templates.ts:54:33 - error TS7006: Parameter 'args' implicitly has an 'any' type.
Any ideas?
42 replies