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

@svforge/audit

v2.0.1

Published

SVForge Audit — business action audit trail (append-only)

Downloads

429

Readme

@svforge/audit

Business action audit trail for SvelteForge dashboard projects — who did what, on which entity, when, with what context. Append-only at the application level.

Install

npx sv add @svforge/audit

Requires the dashboard template (auth + Drizzle). The audit schema is auto-registered in src/lib/server/db/schema.ts.

Deployment profile

Supported: long-lived-node, serverless. Unsupported: edge, separate-worker (the module uses PostgreSQL).

Set a product retention period, classify metadata/PII, and limit read access to administrators. The included API is append-only at application level; where regulatory integrity is required, add a PostgreSQL trigger that rejects UPDATE and DELETE for audit_logs.

Record

import { audit } from '$lib/server/audit';

await audit.record({
	actorId: user.id, // null → system action
	action: 'punch.corrected',
	entityType: 'punch',
	entityId: punch.id,
	metadata: {
		before: { time: oldTime },
		after: { time: newTime },
		reason
	},
	ipAddress: event.getClientAddress(),
	userAgent: event.request.headers.get('user-agent')
});

Read

await audit.forEntity('punch', punchId);       // full history, newest first
await audit.byActor(userId, { limit: 50 });    // actions by one actor
await audit.list({ action: 'punch.corrected', entityType: 'punch', limit: 50, offset: 0 });

Admin view

/admin/audit — filter by action/entity, paginated, admin-only (same guard as the other admin pages).

Model

{ id, actorId?, action, entityType, entityId?, metadata?, ipAddress?, userAgent?, createdAt }

🔒 Confidentiality — what must NEVER go in metadata

  • passwords, tokens, session secrets
  • full object dumps containing sensitive data
  • PII beyond what the feature genuinely needs
  • card numbers / billing details

The audit log is a business trail, not a technical log and not an event-sourcing store. No update/delete is exposed by the API — the table stays append-only at the application level.

For a database-enforced policy, run this product-owned migration (adapt the retention window to your legal requirements):

CREATE FUNCTION reject_audit_mutation() RETURNS trigger LANGUAGE plpgsql AS $$
BEGIN
  RAISE EXCEPTION 'audit_logs is append-only';
END;
$$;
CREATE TRIGGER audit_logs_append_only
  BEFORE UPDATE OR DELETE ON audit_logs
  FOR EACH ROW EXECUTE FUNCTION reject_audit_mutation();
-- Example retention job, not a module default:
-- DELETE FROM audit_logs WHERE created_at < now() - interval '2 years';

What's included

  • $lib/server/audit/schema.ts — Drizzle schema (audit_logs)
  • $lib/server/audit/index.tsaudit.record / forEntity / byActor / list
  • src/routes/(app)/admin/audit/ — paginated admin view (FR/EN via Paraglide)

Limits (v1)

  • Append-only at the application level only — there is no retention policy / pruning in v1. Add a cleanup job when volume grows.
  • metadata is a JSONB free-form map: keep it small and non-sensitive (see confidentiality above).
  • List endpoint is a simple page-based read; no search/indexing in v1.

License

MIT