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

@airdraft/plugin-audit-log

v0.1.8

Published

Audit logging plugin for Airdraft — emits a wide event per CMS request

Readme

@airdraft/plugin-audit-log

Wide-event audit logging plugin for Airdraft. Captures every CMS operation — including actor, collection, slug, HTTP method, status, duration, and per-field validation errors — and routes them to configurable persisters.

Installation

npm install @airdraft/plugin-audit-log

Usage

import { defineConfig } from '@airdraft/core'
import { withAuditLog } from '@airdraft/plugin-audit-log'

export const airdraft = defineConfig({
  adapter,
  collections,
  plugins: [
    withAuditLog({ logFilePath: './logs/audit.log' }),
  ],
})

Options

| Option | Type | Default | Description | |---|---|---|---| | logFilePath? | string | — | Path to an NDJSON audit log file. Also enables the GET /audit route on the handler. | | persist? | AuditPersister | consolePersister (or filePersister if logFilePath is set) | Custom persister function. |

GET /audit endpoint

When logFilePath is set, a /audit route is added to the CMS handler:

GET /api/cms/audit?limit=50&offset=0
→ { events: AuditEvent[], total: number }

Persisters

consolePersister

Logs each event as a compact JSON line to stdout (default).

import { consolePersister } from '@airdraft/plugin-audit-log'
withAuditLog({ persist: consolePersister })

filePersister(filePath)

Appends events as NDJSON to a file. Compatible with jq, grep, and log shippers (Loki, Datadog, etc.).

import { filePersister } from '@airdraft/plugin-audit-log'
withAuditLog({ persist: filePersister('./logs/audit.log') })

compositePersister(...persisters)

Calls multiple persisters in sequence — useful for logging to both console and file simultaneously.

import { compositePersister, consolePersister, filePersister } from '@airdraft/plugin-audit-log'

withAuditLog({
  persist: compositePersister(
    consolePersister,
    filePersister('./logs/audit.log'),
  ),
})

mongodbPersister(collection)

Inserts events into a MongoDB collection. Pass any object with an insertOne method — compatible with the official mongodb driver. No mongodb peer dependency is required.

import { MongoClient } from 'mongodb'
import { mongodbPersister } from '@airdraft/plugin-audit-log'

const db = new MongoClient(process.env.MONGODB_URI!).db('mydb')
withAuditLog({ persist: mongodbPersister(db.collection('auditLogs')) })

The MongoInsertableCollection interface is exported for use in custom adapters:

import type { MongoInsertableCollection } from '@airdraft/plugin-audit-log'

AuditEvent shape

interface AuditEvent {
  id: string           // unique event ID
  timestamp: string    // ISO-8601
  method: string       // 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'
  path: string         // request path, e.g. '/posts/hello-world'
  action: string       // e.g. 'entry.create', 'media.upload', 'schema.update'
  collection?: string
  slug?: string
  statusCode: number
  durationMs: number
  actor?: string       // raw API key / bearer token
  error?: {
    message: string
    code: string
    details?: Array<{ field: string; message: string }>  // per-field validation errors
  }
}

Exports

| Export | Description | |---|---| | withAuditLog(options?) | Creates the audit log plugin | | consolePersister | Default stdout persister | | filePersister(filePath) | NDJSON file persister | | compositePersister(...persisters) | Fan-out persister | | mongodbPersister(collection) | MongoDB insert persister | | AuditPersister | Type: (event: AuditEvent) => void \| Promise<void> | | AuditLogOptions | Options type for withAuditLog | | MongoInsertableCollection | Duck-typed interface for the MongoDB persister |

Changelog

See CHANGELOG.md.