mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 00:25:38 -04:00
Docker self-hosting support: - Dockerfile (multi-stage Alpine build with tini init) - docker-compose.yml with named volume for SQLite persistence - /api/health endpoint for container health checks - Auto-migration on startup via drizzle-orm/libsql/migrator - Graceful shutdown (SIGTERM stops scheduler, closes DB) - Next.js standalone output mode for minimal image size Database driver migration (better-sqlite3 → @libsql/client): - Eliminates native C++ compilation, enabling Alpine Docker images - All DB queries converted from sync to async across services and routes - DATABASE_URL now uses libsql file: prefix format - drizzle.config.ts dialect changed to turso for libsql support - Initial migration files generated in drizzle/ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
31 lines
896 B
TypeScript
31 lines
896 B
TypeScript
import { headers } from "next/headers";
|
|
import type { NextRequest } from "next/server";
|
|
import { NextResponse } from "next/server";
|
|
import { auth } from "@/lib/auth/server";
|
|
import { rateTitleStars } from "@/lib/services/tracking";
|
|
|
|
export async function POST(
|
|
req: NextRequest,
|
|
{ params }: { params: Promise<{ id: string }> },
|
|
) {
|
|
const session = await auth.api.getSession({
|
|
headers: await headers(),
|
|
});
|
|
if (!session)
|
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
|
|
const { id } = await params;
|
|
const body = await req.json();
|
|
const { ratingStars } = body;
|
|
|
|
if (typeof ratingStars !== "number" || ratingStars < 0 || ratingStars > 5) {
|
|
return NextResponse.json(
|
|
{ error: "ratingStars must be 0-5" },
|
|
{ status: 400 },
|
|
);
|
|
}
|
|
|
|
await rateTitleStars(session.user.id, id, ratingStars);
|
|
return NextResponse.json({ ok: true });
|
|
}
|