npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@helpful-insight/logger

v1.0.3

Published

High-performance Pino logger, request/response tracer, and compliance audit trail system for Express

Readme

@helpful-insight/logger

npm version License: MIT TypeScript

High-performance structured logger, request correlation tracer, and SOC2/HIPAA compliance audit trail service for Node.js, Express, and Prisma. Built on top of Pino with automatic recursive redaction of sensitive credentials, distributed request tracing (x-request-id), and Prisma audit trail storage.


🌟 Key Features

  • ⚡ High-Speed Structured Logging (Pino):
    • Minimal CPU & memory overhead.
    • Formatted pretty-print in development; JSON formatted in production for Datadog, CloudWatch, or ELK.
  • 🔒 Automatic Sensitive Data Redaction:
    • Deep recursive masking of sensitive keys: password, token, secret, apiKey, authorization, creditCard, cvv, etc.
    • Masks data before writing to logs or audit records ([REDACTED]).
  • 🔗 Distributed Request Tracing (x-request-id):
    • Automatically inspects or generates unique request correlation IDs (x-request-id / x-correlation-id).
    • Injects contextual child loggers (req.log) into every incoming request.
  • 📜 Enterprise Compliance Audit Trail:
    • Track critical business actions: Actor (User/System), Action (USER_UPDATED, INVOICE_PAID), Resource, Target ID, Old Values, New Values, IP, and User-Agent.
    • Pluggable repositories: Zero-config in-memory store and production Prisma database adapter.
  • 🚀 Express HTTP Middleware:
    • Logs request lifecycle (Method, Path, Status Code, Response Duration in ms).
    • Auto-audit capability with path filtering (e.g. ignore /health).

📦 Installation

# npm
npm install @helpful-insight/logger

# pnpm
pnpm add @helpful-insight/logger

# yarn
yarn add @helpful-insight/logger

🚀 Quick Start

1. Basic Structured Logging

import { logger } from '@helpful-insight/logger';

logger.info({ userId: 'u_123' }, 'User logged in successfully');
logger.warn('Rate limit approaching threshold');
logger.error(new Error('Database connection failed'), 'Unhandled error');

2. Masking Sensitive Payloads

import { maskSensitiveData } from '@helpful-insight/logger';

const clean = maskSensitiveData({
  username: 'john_doe',
  password: 'SuperSecretPassword!',
  nested: {
    apiKey: 'sk_live_123456789'
  }
});

console.log(clean);
// {
//   username: 'john_doe',
//   password: '[REDACTED]',
//   nested: { apiKey: '[REDACTED]' }
// }

3. Compliance Audit Trail

import { AuditService, MemoryAuditRepository } from '@helpful-insight/logger';

const repo = new MemoryAuditRepository(); // or new PrismaAuditRepository(prisma)
const auditService = new AuditService(repo);

// Record business event
await auditService.record({
  actor: { id: 'admin_1', type: 'user', email: '[email protected]' },
  action: 'UPDATE_ROLE',
  resource: 'User',
  targetId: 'user_42',
  oldValues: { role: 'editor' },
  newValues: { role: 'admin' },
  ip: '192.168.1.1'
});

// Fetch recent audit logs
const logs = await auditService.getRecent(10);

🌐 Express HTTP Middleware

import express from 'express';
import { createHttpLoggerMiddleware, logger, AuditService, MemoryAuditRepository } from '@helpful-insight/logger';

const app = express();
app.use(express.json());

const auditService = new AuditService(new MemoryAuditRepository());

app.use(createHttpLoggerMiddleware({
  logger,
  auditService,
  logBody: true,                       // Sanitizes and logs request body
  autoAudit: false,                     // Auto-audits state-changing HTTP calls (POST, PUT, DELETE)
  excludeAuditPaths: ['/health', '/metrics']
}));

app.post('/api/users/:id/promote', async (req, res) => {
  // Use child logger with request ID attached
  req.log.info('Promoting user');

  // Record audit trail via request helper
  await req.audit({
    action: 'PROMOTE_USER',
    resource: 'User',
    targetId: req.params.id
  });

  res.json({ success: true });
});

🗄️ Prisma Audit Model

model AuditLog {
  id          String   @id @default(uuid())
  actorId     String?
  actorType   String
  action      String
  resource    String
  targetId    String?
  oldValues   String?  // JSON string
  newValues   String?  // JSON string (sanitized)
  ip          String?
  userAgent   String?
  requestId   String?
  timestamp   DateTime @default(now())
}

📄 License

MIT © Helpful Insight Private Limited