tip #38: Audit-Log: who changed what
This commit is contained in:
@@ -30,3 +30,4 @@ Going forward, new tips are pushed automatically by the `mc_survival_tips.py` cr
|
||||
- [Tip #37](tips/2026-07-17-037-search-fuzzy-search-for-items-recipes.md) (2026-07-17) — **search**: Fuzzy-Search for items & recipes
|
||||
- [Tip #37](tips/2026-07-17-037-crafting-ux-missing-item-highlight-in-recipe.md) (2026-07-17) — **crafting-ux**: Missing-item highlight in recipe
|
||||
- [Tip #37](tips/2026-07-18-037-search-fuzzy-search-for-items-recipes.md) (2026-07-18) — **search**: Fuzzy-Search for items & recipes
|
||||
- [Tip #38](tips/2026-07-19-038-admin-audit-log-who-changed-what.md) (2026-07-19) — **admin**: Audit-Log: who changed what
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
tip_number: 38
|
||||
date: 2026-07-19
|
||||
category: admin
|
||||
status: pending
|
||||
---
|
||||
|
||||
# Tip #38 — Audit-Log: who changed what
|
||||
|
||||
**Date:** 2026-07-19
|
||||
**Category:** admin
|
||||
**Source:** MC-Survival Wiki Daily Tip (cron @ 18:00 MESZ)
|
||||
|
||||
## Audit-Log: who changed what
|
||||
|
||||
An audit log is a dedicated Prisma model that records every editor mutation — who did what, on which entity, with the before/after snapshot and a timestamp. It solves the inevitable 'who broke the diamond-sword recipe' question that appears as soon as there is more than one editor. The signal is operational: we are about to invite moderators, and without an audit trail every content dispute becomes a he-said-she-said. A withAudit(fn, action) helper that wraps existing mutations keeps the call-site change to one line, which matters because a feature that requires editing 30 endpoints will not get merged.
|
||||
|
||||
## Implementation tips
|
||||
|
||||
1. New Prisma model: AuditLog { id, userId, action, entityType, entityId, before, after, createdAt }.
|
||||
2. Wrap all editor mutations in functions.ts with a small withAudit(fn, action) helper — one line per call site.
|
||||
3. Add a /admin/audit route with filter by user, entity, date range.
|
||||
Reference in New Issue
Block a user