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

@croco/audit-drizzle

v0.0.2

Published

`@croco/audit-core`용 Drizzle 감사 로그 저장소입니다.

Readme

@croco/audit-drizzle

@croco/audit-core용 Drizzle 감사 로그 저장소입니다.

설치

pnpm add @croco/audit-drizzle @croco/audit-core @croco/tx-core drizzle-orm

사용법

import Database from "better-sqlite3";
import { drizzle } from "drizzle-orm/better-sqlite3";
import { TxManager } from "@croco/tx-core";
import { createDrizzleTxAdapter } from "@croco/tx-drizzle";
import { DrizzleAuditLogRepository, auditLogsSqlite } from "@croco/audit-drizzle";

const sqlite = new Database(":memory:");
const db = drizzle(sqlite);

const adapter = createDrizzleTxAdapter(db);
const txManager = new TxManager(adapter, { defaultNesting: "join" });

const repository = new DrizzleAuditLogRepository(db, txManager, {
  table: auditLogsSqlite,
  schema: {
    id: auditLogsSqlite.id,
    tenantId: auditLogsSqlite.tenantId,
    actorId: auditLogsSqlite.actorId,
    action: auditLogsSqlite.action,
    resourceType: auditLogsSqlite.resourceType,
    resourceId: auditLogsSqlite.resourceId,
    payload: auditLogsSqlite.payload,
    diff: auditLogsSqlite.diff,
    metadata: auditLogsSqlite.metadata,
    createdAt: auditLogsSqlite.createdAt,
  },
});

const entry = await repository.create({
  tenantId: "tenant-1",
  actorId: "user-1",
  action: "user.update",
  resourceType: "User",
  resourceId: "user-1",
  payload: { email: "[email protected]" },
  diff: { email: { before: "[email protected]", after: "[email protected]" } },
  metadata: { requestId: "req-1" },
});

const logs = await repository.find({ tenantId: "tenant-1", limit: 10 });

SQLite에서는 기본 직렬화기를 그대로 쓰고, PostgreSQL JSONB를 사용할 때는 serializeJson, deserializeJson을 직접 넘길 수 있습니다.

API 레퍼런스

DrizzleAuditLogRepository

  • create(entry), 감사 로그를 저장합니다.
  • find(query), 테넌트 기준 목록을 조회합니다.
  • findByDateRange(...), 기간 범위로 조회합니다.
  • findByActor(...), 액터 기준으로 조회합니다.
  • findByResource(...), 리소스 기준으로 조회합니다.

Schema

  • auditLogsPg, PostgreSQL용 감사 로그 스키마입니다.
  • auditLogsSqlite, SQLite용 감사 로그 스키마입니다.
  • AuditLogTable, 저장소 설정에 사용하는 컬럼 매핑 타입입니다.
  • DrizzleAuditLogRepositoryConfig, 직렬화기와 스키마를 묶는 설정 타입입니다.