feat(social): follows, favorites, comments, reactions, collections, public profiles

Follow/unfollow users. Recipe favorites. Threaded comments with emoji reactions.
Collections (public/private) with shared member invite. Activity feed.
Public profile pages at /u/[username].
This commit is contained in:
Arnaud
2026-07-01 08:10:30 +02:00
parent d9d58fd01a
commit 9d02a69250
23 changed files with 1825 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
import { NextRequest, NextResponse } from "next/server";
import { z } from "zod";
import { db, collections, eq, desc } from "@epicure/db";
import { requireSession } from "@/lib/api-auth";
const Schema = z.object({
name: z.string().min(1).max(100),
description: z.string().max(500).optional(),
isPublic: z.boolean().default(false),
});
export async function GET(_req: NextRequest) {
const { session, response } = await requireSession();
if (response) return response;
const rows = await db.query.collections.findMany({
where: eq(collections.userId, session!.user.id),
orderBy: desc(collections.updatedAt),
with: { recipes: { limit: 4, with: { recipe: { with: { photos: true } } } } },
});
return NextResponse.json(rows);
}
export async function POST(req: NextRequest) {
const { session, response } = await requireSession();
if (response) return response;
const body = await req.json() as unknown;
const parsed = Schema.safeParse(body);
if (!parsed.success) return NextResponse.json({ error: "Validation error" }, { status: 400 });
const id = crypto.randomUUID();
await db.insert(collections).values({
id,
userId: session!.user.id,
name: parsed.data.name,
description: parsed.data.description,
isPublic: parsed.data.isPublic,
});
return NextResponse.json({ id }, { status: 201 });
}