Here is my query:
import { getAuthUserId } from "@convex-dev/auth/server"
import { query } from "@cvx/_generated/server"
export const getCurrentUser = query({
args: {},
handler: async (ctx) => {
const userId = await getAuthUserId(ctx)
if (!userId) return null
const user = await ctx.db.get(userId)
if (!user) return null
return user
},
})
Then I have a wrapper function like this:
import { getAuthUserId } from "@convex-dev/auth/server"
import { customCtx } from "convex-helpers/server/customFunctions"
import { zCustomMutation, zCustomQuery } from "convex-helpers/server/zod"
import { ConvexError } from "convex/values"
import { mutation, query } from "@cvx/_generated/server"
import { getCurrentUser } from "@cvx/users/queries"
export const authenticatedQuery = zCustomQuery(
query,
customCtx(async (ctx) => {
const user = await getCurrentUser(ctx)
if (!user) throw new ConvexError("Unauthorized")
return { user }
})
)
Here is the typescript error:
This expression is not callable.
Type 'RegisteredQuery<"public", {}, Promise<{ _id: Id<"users">; _creationTime: number; image?: string | undefined; name: string; email: string; isAuthorized: boolean; } | null>>' has no call signatures
How can I call the getCurrentUser inside the customCtx?