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 🙏

© 2024 – Pkg Stats / Ryan Hefner

audit-logs-package

v1.0.6

Published

This is is a Node.js package for logging audit messages to a database. It uses Sequelize as an ORM for database interactions

Downloads

3

Readme

Audit Logs Package

Audit Logs Package is a Node.js package for logging audit messages to a database. It uses Sequelize as an ORM for database interactions.

Features

  • Define Sequelize model for Audit Log.
  • Create audit logs with detailed information.

Getting Started

  1. Installation
npm install audit-logs-package

How to use Audit Logs package

const { Sequelize } = require('sequelize');
const { defineAuditLogModel, createAuditLog, closeConnection } = require('audit-logs-package');

// Initialize Sequelize instance
const sequelize = new Sequelize(/* Your database connection options */);

// Define AuditLog model
const AuditLog = defineAuditLogModel(sequelize);

// Example: Create an audit log
const auditLogParams = {
  entityName: 'User',
  entityId: '123',
  tenantId: '456',
  action: 'UPDATE',
  previousRecord: /* Your previous record */,
  currentRecord: /* Your current record */,
  createdById: '789',
};

await createAuditLog(auditLogParams, AuditLog);

// Close the database connection on process exit
closeConnection(sequelize);
  1. Model Details

The defineAuditLogModel function creates a Sequelize model for the Audit Log with the following properties:

  • id: UUID primary key.
  • entityName: String (255) representing the entity name.
  • entityId: String (255) representing the entity ID.
  • tenantId: Optional UUID for multi-tenancy support.
  • action: String (32) representing the action performed.
  • createdById: Optional UUID representing the user who created the log.
  • timestamp: Date representing the log creation time.
  • previousRecord: JSON representing the previous state.
  • currentRecord: JSON representing the current state.

Logging Function

The createAuditLog function is used to create an audit log with the specified parameters.

  • params: An object containing the audit log details.
  • AuditLog: The Sequelize model for Audit Log.

The log function handles the actual creation of the log and includes error handling.

Closing Connection

The closeConnection function can be used to close the Sequelize database connection when your application exits.