Jun-del/wr-audit-logger ? reverse-engineered prompt
Reverse engineered prompt
Build me a TypeScript library for Drizzle ORM with PostgreSQL that adds automatic audit logging without me having to sprinkle logging calls all over my app.
I want to wrap my existing database client and have inserts, updates, and deletes on selected tables get logged automatically with who did it, when it happened, what table changed, the record id, and the before and after values. It should support setting request context like user id, ip address, user agent, and extra metadata from middleware, and it should let me choose which tables and fields to track, plus exclude sensitive fields like passwords or tokens.
Please include a way to create the audit table schema, with support for custom table names and column names, and make it possible to use a custom writer if I want to store logs somewhere else. It should also handle batch writing for better performance, and have a strict mode if I want audit failures to block the main DB action.
If you need anything unclear, look up the latest Drizzle docs online and keep the API pleasant to use.
Are you gonna build this?
make sure you review the code using coderabbit