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

@nathapp/nestjs-audit

v3.3.0

Published

Decorator-driven, storage-agnostic audit logging for NestJS applications

Downloads

62

Readme

@nathapp/nestjs-audit

Decorator-driven, storage-agnostic audit logging for NestJS applications.

Features

  • Declarative capture@Audit({ action, resource? }) on a controller/service method, picked up by AuditInterceptor
  • Pluggable storageIAuditStorage seam; ships InMemoryAuditStorage (default) and LoggerAuditStorage; bring your own Prisma/TypeORM-backed storage
  • Pluggable actor resolutionIAuditActorResolver seam; ships DefaultActorResolver (req.user?.id ?? 'anonymous')
  • Never fails the request — audit storage write failures are caught and logged, not propagated to the response
  • Correlation-id aware — reads @nathapp/nestjs-logging's request-scoped correlation id automatically

Installation

npm install @nathapp/nestjs-audit @nathapp/nestjs-common @nathapp/nestjs-logging

Peer requirement: ClockModule. AuditModule does not import ClockModule itself — AuditInterceptor depends on the CLOCK token from @nathapp/nestjs-common, and expects it to already be available in your application's module tree, the same way LoggerAuditStorage expects LOGGER_SERVICE to already be available. Most apps already satisfy this if they use nestjs-common's clock seam anywhere else, since ClockModule is global: true. If yours doesn't, add ClockModule.register() to your root module's imports — otherwise Nest will throw a dependency-resolution error at bootstrap.

Quick Start

import { Module } from '@nestjs/common';
import { AuditModule } from '@nathapp/nestjs-audit';

@Module({
  imports: [AuditModule.register()],
})
export class AppModule {}
import { Audit, AuditInterceptor } from '@nathapp/nestjs-audit';

@Controller('users')
@UseInterceptors(AuditInterceptor)
export class UsersController {
  @Audit({ action: 'USER_UPDATED', resource: 'user', resourceIdParam: 'id' })
  @Patch(':id')
  updateUser(@Param('id') id: string, @Body() dto: UpdateUserDto) {
    return this.usersService.update(id, dto);
  }
}

Custom storage

import { AuditModule } from '@nathapp/nestjs-audit';

@Module({
  imports: [
    AuditModule.registerAsync({
      useFactory: (prisma: PrismaService) => ({ storage: new PrismaAuditStorage(prisma) }),
      inject: [PrismaService],
    }),
  ],
})
export class AppModule {}

Scope

v1 does not include automatic before/after state diffing — pass whatever context you need through IAuditStorage directly if you need it, since AuditEntry.metadata is available to any direct storage consumer (not populated by AuditInterceptor itself, since @Audit() options are static and set at method-definition time).

Security

AuditEntry.metadata and the built-in LoggerAuditStorage write whatever is passed through verbatim (including to structured logs). Do not put secrets, API keys, passwords, or other sensitive personally-identifiable information into metadata — treat it the same way you would any other logged field.