Initial commit — Grow baby tracker

Next.js 16 App Router, Prisma + PostgreSQL, NextAuth v5 JWT.

Features: dashboard quick-log, timeline, growth charts (WHO percentiles),
stats, journal/notes, doctor notes, milestones, vaccinations, settings,
superadmin panel. Mobile-first with sidebar nav + bottom nav + quick-add FAB.
Dark mode, PWA push notifications, multi-family invite system.

Docker: multi-stage Dockerfile + docker-compose with postgres service.
This commit is contained in:
2026-06-13 01:52:46 +02:00
commit cd16c354c0
94 changed files with 14354 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
import { NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
export async function PATCH(
req: Request,
{ params }: { params: Promise<{ id: string }> }
) {
const session = await auth();
if (!session?.user?.id) return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
const { id } = await params;
const body = await req.json();
const event = await prisma.event.update({
where: { id },
data: {
...(body.notes !== undefined ? { notes: body.notes } : {}),
...(body.startedAt ? { startedAt: new Date(body.startedAt) } : {}),
...(body.endedAt !== undefined
? { endedAt: body.endedAt ? new Date(body.endedAt) : null }
: {}),
...(body.metadata !== undefined ? { metadata: body.metadata } : {}),
},
include: { user: { select: { id: true, name: true } } },
});
return NextResponse.json(event);
}
export async function DELETE(
_req: Request,
{ params }: { params: Promise<{ id: string }> }
) {
const session = await auth();
if (!session?.user?.id) return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
const { id } = await params;
await prisma.event.delete({ where: { id } });
return new NextResponse(null, { status: 204 });
}
+67
View File
@@ -0,0 +1,67 @@
import { NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
export async function GET(req: Request) {
const session = await auth();
if (!session?.user?.id) return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
const { searchParams } = new URL(req.url);
const babyId = searchParams.get("babyId");
const limit = parseInt(searchParams.get("limit") ?? "50");
const offset = parseInt(searchParams.get("offset") ?? "0");
const type = searchParams.get("type");
const dateFrom = searchParams.get("dateFrom");
const dateTo = searchParams.get("dateTo");
if (!babyId) return NextResponse.json({ error: "babyId requis" }, { status: 400 });
const where: Record<string, unknown> = { babyId };
if (type) where.type = type;
if (dateFrom || dateTo) {
where.startedAt = {
...(dateFrom ? { gte: new Date(dateFrom) } : {}),
...(dateTo ? { lte: new Date(dateTo) } : {}),
};
}
const [events, total] = await Promise.all([
prisma.event.findMany({
where,
orderBy: { startedAt: "desc" },
take: limit,
skip: offset,
include: { user: { select: { id: true, name: true } } },
}),
prisma.event.count({ where }),
]);
return NextResponse.json({ events, total });
}
export async function POST(req: Request) {
const session = await auth();
if (!session?.user?.id) return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
const body = await req.json();
const { babyId, type, startedAt, endedAt, notes, metadata } = body;
if (!babyId || !type || !startedAt) {
return NextResponse.json({ error: "Champs requis manquants" }, { status: 400 });
}
const event = await prisma.event.create({
data: {
babyId,
userId: session.user.id,
type,
startedAt: new Date(startedAt),
endedAt: endedAt ? new Date(endedAt) : null,
notes: notes ?? null,
metadata: metadata ?? null,
},
include: { user: { select: { id: true, name: true } } },
});
return NextResponse.json(event, { status: 201 });
}