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

audit-log-middleware

v1.0.0

Published

Express middleware for logging user activities with configurable detail levels and export options

Downloads

3

Readme

🎯 Audit Log Middleware

A powerful middleware for logging user activities in your Express applications.

✨ Features

  • 📝 Automatically captures relevant data:
    • User information
    • Endpoint accessed
    • HTTP method
    • Date and time
    • Request body details
  • 🔧 Configurable detail levels (basic, intermediate, complete)
  • 💾 Export options:
    • JSON files
    • CSV files
    • External services (Elasticsearch)

🎯 Use Cases

  • 📋 Applications requiring audit trails (e.g., GDPR or HIPAA compliance)
  • 📊 Internal application monitoring
  • 🔍 User activity tracking
  • 🛡️ Security logging

🚀 Installation

npm install audit-log-middleware

📖 Basic Usage

const express = require("express");
const { createAuditMiddleware } = require("audit-log-middleware");

const app = express();

// Basic audit middleware configuration
const auditMiddleware = createAuditMiddleware({
  level: "complete",
  storage: {
    type: "file",
    options: {
      filename: "audit-logs.json",
    },
  },
});

// Apply middleware globally
app.use(auditMiddleware);

📝 Example Output

[
  {
    "timestamp": "2024-01-01T12:00:00.000Z",
    "userId": "user123",
    "method": "GET",
    "endpoint": "/users/1",
    "userAgent": "Mozilla/5.0 (compatible; ExampleBrowser/1.0)",
    "ip": "71.198.38.7",
    "responseStatus": 200
  },
  {
    "timestamp": "2024-01-01T12:01:00.000Z",
    "userId": "user123",
    "method": "GET",
    "endpoint": "/",
    "userAgent": "Mozilla/5.0 (compatible; ExampleBrowser/1.0)",
    "ip": "216.73.163.219",
    "responseStatus": 200,
    "responseBody": "{\"message\":\"Hello World!\"}"
  }
]

⚙️ Configuration Options

Detail Levels

  • basic: Logs only essential information
  • intermediate: Adds request headers and response status
  • complete: Includes full request and response details

Storage Options

// File storage
{
  type: 'file',
  options: {
    filename: 'audit-logs.json'
  }
}
// Elasticsearch storage
{
  type: 'elasticsearch',
  options: {
    node: 'http://localhost:9200',
    index: 'audit-logs'
  }
}

🔒 Security Considerations

  • Sensitive data can be filtered out using the exclude option
  • Supports data encryption for stored logs
  • Compliant with common security standards

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.