Initial commit for project Spoon!
Build and Push Next App / quality (push) Failing after 45s
Build and Push Next App / build-next (push) Has been skipped

This commit is contained in:
Gabriel Brown
2026-06-21 17:52:02 -05:00
commit cf7ff2ee4e
268 changed files with 32981 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
import { getAuthUserId } from '@convex-dev/auth/server';
import { ConvexError } from 'convex/values';
import type { Doc, Id } from './_generated/dataModel';
import type { MutationCtx, QueryCtx } from './_generated/server';
type Ctx = QueryCtx | MutationCtx;
export const getRequiredUserId = async (ctx: Ctx): Promise<Id<'users'>> => {
const userId = await getAuthUserId(ctx);
if (!userId) throw new ConvexError('Not authenticated.');
return userId;
};
export const getOwnedSpoon = async (
ctx: Ctx,
spoonId: Id<'spoons'>,
ownerId: Id<'users'>,
): Promise<Doc<'spoons'>> => {
const spoon = await ctx.db.get(spoonId);
if (spoon?.ownerId !== ownerId) {
throw new ConvexError('Spoon not found.');
}
return spoon;
};
export const requireText = (value: string, label: string): string => {
const trimmed = value.trim();
if (!trimmed) throw new ConvexError(`${label} is required.`);
return trimmed;
};
export const optionalText = (value: string | undefined) => {
const trimmed = value?.trim();
if (!trimmed) return undefined;
return trimmed;
};