Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wizeapps/sequelize-audit

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wizeapps/sequelize-audit

Provides auditing of sequelize models

  • 3.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

@wizeapps/sequelize-audit

Description

Enables auditing on sequelize models. It works on CREATE, UPDATE, DESTROY events on sequelize model instance.

Models

  • WizeAudit: Stores all historical changes performed on model
  • WizeAuditModel: Stores all models on which auditing in enabled

APIs

  • [GET] /api/wizeaudits - Lists all changes performed across all models
  • [GET] /api/wizeaudits/:id - Fetches specific change set for the identifier
  • [GET] /api/wizeauditmodels - Lists all models for which auditing is enabled
  • [POST] /api/wizeauditmodels - Enable auditing on a specific model ({"modelName": "User", "displayField": "FirstName"})
  • [DELETE] /api/wizeauditmodels/:id - Remove auditing on a specific model

Audit Schema

{
  "id": <Auto-increment> INTEGER,
  "diff": JSONB (Difference deep-diff),
  "email": STRING (Actor),
  "identifier": INTEGER (Instance ID),
  "model": STRING (Model),
  "action": CHAR(1) (Action),
  "oldValue": JSONB (Previous state of instance)
}

Usage

Installation

npm install --save @wizeapps/sequelize-audit

Initialize

import wizeSequelizeAudit from '@wizeapps/sequelize-audit';
.
.
.
/*
app: koa-app returned from 'const app = createServer({});'
sequelizeSource: sequelize object returned from 'import sequelizeSource from './sources/postgresql';'
opts: JSON object
*/
wizeSequelizeAudit(app, sequelizeSource, opts);
Opts (Options)
{
  "exclude": ["id", "createdAt", "updatedAt"]
}
Model Definition

Module assumes that model has system fields - createdBy and modifiedBy, which are used to store the actor. These system fields are used to capture the actor information in audit table. Supply createdBy in instance during Create and modifiedBy during Update and Delete operations.

Test

npm run test

License

MIT License

FAQs

Package last updated on 31 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc