msmps
msmps2y ago

Audit logging middleware?

I’m required for regulatory reasons to log all actions that are taken in my application for auditing and if they were successful or not. Imagine - user successfully updated a resource, user viewed <x> resource. Is there a best practice to implementing such behaviour with tRPC? I was originally thinking about a middleware but it would need to know if the action was successful post request. Thanks all.
2 Replies
Nick
Nick2y ago
Middleware is definitely one way, but it’s a fairly blunt instrument. If you want entity aware audit logging then that’s something you’d probably incorporate into some service classes which handle the database interactions You can have a middleware which gets appended after input/output is defined on a procedure, I believe, which might open some interesting doors too
vildantursic
vildantursic10mo ago
@msmps have you found anything interesting? I am also having same requirement and trying to figure out best solution 😄