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

@cepseudo/adonis-audit-log

v1.2.0

Published

Simple audit logging for AdonisJS 6

Readme

@cepseudo/adonis-audit-log

Simple audit logging package for AdonisJS 6.

Features

  • Custom audit logs for tracking user actions and business events
  • Automatic HTTP request logging via middleware
  • Error logging with exception handler integration
  • Configurable field sanitization for sensitive data
  • Retention settings for log cleanup

Installation

npm install @cepseudo/adonis-audit-log

Configuration

node ace configure @cepseudo/adonis-audit-log

This will:

  1. Publish migrations to database/migrations/
  2. Publish config to config/audit.ts
  3. Register the provider and command in adonisrc.ts

Then run the migrations:

node ace migration:run

Configuration Options

// config/audit.ts
import { defineConfig } from '@cepseudo/adonis-audit-log'

export default defineConfig({
  enabled: true,

  requestLog: {
    enabled: true,
    excludeRoutes: ['/health', '/metrics'],
    excludeMethods: ['OPTIONS'],
    logBody: false,
    logQuery: true,
    sanitizeFields: ['password', 'token', 'secret'],
  },

  errorLog: {
    enabled: true,
    excludeStatusCodes: [404],
    includeStack: true,
  },

  auditLog: {
    enabled: true,
  },

  // Retention in days (0 = unlimited)
  retention: {
    requestLogs: 30,
    errorLogs: 90,
    auditLogs: 0, // Keep forever
  },
})

Usage

Custom Audit Logs

import audit from '@cepseudo/adonis-audit-log/services/main'

// Simple log
await audit.log('user.login', { user_id: 1 })

// With metadata
await audit.log('submission.create', {
  user_id: auth.user.id,
  submission_id: submission.id,
  project_acronym: submission.projectAcronym,
})

// Track changes
await audit.logChange('user.update', {
  userId: auth.user.id,
  targetId: targetUser.id,
  changes: {
    email: { from: '[email protected]', to: '[email protected]' },
  },
})

Request Logging (Middleware)

Add the middleware to your router in start/kernel.ts:

router.use([() => import('@cepseudo/adonis-audit-log/middleware/request_logger')])

Error Logging (Exception Handler)

Integrate with your exception handler in app/exceptions/handler.ts:

import { AuditErrorLogger } from '@cepseudo/adonis-audit-log'

export default class HttpExceptionHandler extends ExceptionHandler {
  async report(error: unknown, ctx: HttpContext) {
    await AuditErrorLogger.log(error, ctx)
    return super.report(error, ctx)
  }
}

Log Cleanup

Delete old logs based on retention configuration:

node ace audit:cleanup

Set retention to 0 for unlimited retention (logs won't be deleted).

Database Schema

The package creates three tables:

audit_logs

  • id - Primary key
  • action_type - Event type (e.g., 'user.login', 'submission.create')
  • metadata - JSON object with additional data
  • user_id - Optional reference to users table
  • created_at - Timestamp

request_logs

  • id - Primary key
  • method - HTTP method
  • url - Request URL
  • route_name - Named route if available
  • status_code - HTTP response status
  • response_time_ms - Response time in milliseconds
  • ip - Client IP address
  • user_agent - Browser/client user agent
  • user_id - Optional reference to users table
  • request_body - Sanitized request body (optional)
  • request_query - Query parameters
  • created_at - Timestamp

error_logs

  • id - Primary key
  • error_type - Error class name
  • message - Error message
  • stack - Stack trace (optional)
  • url - URL where error occurred
  • method - HTTP method
  • status_code - HTTP status returned
  • user_id - Optional reference to users table
  • context - Additional context (params, query)
  • created_at - Timestamp

Development

# Install dependencies
npm install

# Run tests
npm run test

# Run tests without linting
npm run quick:test

# Build
npm run build

# Type check
npm run typecheck

# Lint
npm run lint

# Format
npm run format

License

MIT