Visitors comment with just a name and email; a checkbox controls whether the email is shown publicly (default private — only the admin sees it). Every comment lands as pending and is invisible until approved on the new /admin/comments page (approve / unapprove / delete, with a pending-count badge in the admin nav and a dashboard stat). Replies nest under their parent; a reply is only accepted on an approved comment of the same post, and replies stay hidden while their parent is unapproved so threads never render out of context. A hidden honeypot field silently drops naive bots. Comment bodies are plain text, rendered escaped. The backup format gains a comments section (export version 2; v1 files still import) with parent links remapped through file-local ids. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
10 lines
326 B
TypeScript
10 lines
326 B
TypeScript
import { sql } from "drizzle-orm";
|
|
import { db } from "@/db";
|
|
|
|
/** Wipes every table between tests; identities restart at 1. */
|
|
export async function resetDb(): Promise<void> {
|
|
await db.execute(
|
|
sql`TRUNCATE users, sessions, posts, tags, post_tags, pages, nav_items, settings, comments RESTART IDENTITY CASCADE`,
|
|
);
|
|
}
|