import {
customCtx,
customMutation,
customQuery,
type CustomBuilder,
} from "convex-helpers/server/customFunctions";
const authenticatedQueryCtx = customCtx(async (ctx: AuthCtx) => {
const user = await requireAuthUser(ctx);
return { user };
});
const authenticatedMutationCtx = customCtx(async (ctx: AuthCtx) => {
const user = await requireAuthUser(ctx);
return { user };
});
export const authenticatedQuery: CustomBuilder<
"query",
Record<string, never>,
{ user: Doc<"users"> },
Record<string, never>,
QueryCtx,
"public",
object
> = customQuery(query, authenticatedQueryCtx);
export const authenticatedMutation: CustomBuilder<
"mutation",
Record<string, never>,
{ user: Doc<"users"> },
Record<string, never>,
MutationCtx,
"public",
object
> = customMutation(mutation, authenticatedMutationCtx);
import {
customCtx,
customMutation,
customQuery,
type CustomBuilder,
} from "convex-helpers/server/customFunctions";
const authenticatedQueryCtx = customCtx(async (ctx: AuthCtx) => {
const user = await requireAuthUser(ctx);
return { user };
});
const authenticatedMutationCtx = customCtx(async (ctx: AuthCtx) => {
const user = await requireAuthUser(ctx);
return { user };
});
export const authenticatedQuery: CustomBuilder<
"query",
Record<string, never>,
{ user: Doc<"users"> },
Record<string, never>,
QueryCtx,
"public",
object
> = customQuery(query, authenticatedQueryCtx);
export const authenticatedMutation: CustomBuilder<
"mutation",
Record<string, never>,
{ user: Doc<"users"> },
Record<string, never>,
MutationCtx,
"public",
object
> = customMutation(mutation, authenticatedMutationCtx);