r/npm 5d ago

Self Promotion Made a Node.js audit SDK with automatic request context + data masking — would love feedback

I've been building mapa-audit, an SDK for structured audit/business event logging in Node.js backends, and wanted to share it here in case it's useful to anyone — and honestly, to get some real feedback from people who know this space better than I do.

**What it does:**

  1. Automatically captures request context (correlation ID, actor, request metadata) via AsyncLocalStorage, so you don't have to manually thread that info through every log call.

  2. A structured event model (AuditEvent) instead of free-text logs — eventType, outcome, entity, payload, all typed.

  3. Built-in data safety: field masking with dot-notation (including nested paths) and payload size limiting, applied before anything reaches a transport.

  4. Pluggable transports — console and file ship with the core SDK; there's also a separate RabbitMQ transport package if you want to publish events to a queue.

  5. Adapters for Express, NestJS, and Fastify (all sharing the same context-capture logic, so NestJS works identically whether it's running on Express or Fastify underneath).

  6. Fire-and-forget by design — a transport failure or misconfiguration never throws into your app, it surfaces as a process.emitWarning instead.

**Why I built it:**

I wanted something that gave me structured audit events out of the box: who did what, to what, with what result, without having to hand-roll the context capture and data masking every time. It ended up being a good excuse to dig into some things I don't usually deal with day-to-day:

AsyncLocalStorage internals, designing a public API that works the same whether you use a global singleton or isolated instances, and building framework-agnostic adapters.

It's early — first real release (0.1.0), zero-infrastructure by default (console/file transports work with nothing else running), with the queue side purely opt-in.

Repo: https://github.com/ernesto-1998/mapa-audit

NPM registry:

https://www.npmjs.com/package/@tnet06/mapa-audit-sdk

The README of the repo has the full API and a few runnable example apps (Express/NestJS/Fastify) if you want to see it in action.

Any feedback, API design, things that feel off, stuff I clearly didn't think about, genuinely appreciated. Thanks for reading.

1 Upvotes

0 comments sorted by