Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eden-js/audit
https://github.com/eden-js/audit
Last synced: 27 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/eden-js/audit
- Owner: eden-js
- Created: 2019-02-12T01:10:47.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-05-31T17:31:34.000Z (over 3 years ago)
- Last Synced: 2024-04-16T01:08:11.291Z (8 months ago)
- Language: JavaScript
- Size: 194 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# EdenJS - Audit
[![TravisCI](https://travis-ci.com/eden-js/audit.svg?branch=master)](https://travis-ci.com/eden-js/audit)
[![Issues](https://img.shields.io/github/issues/eden-js/audit.svg)](https://github.com/eden-js/audit/issues)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/eden-js/audit)
[![Awesome](https://img.shields.io/badge/awesome-true-green.svg)](https://github.com/eden-js/audit)
[![Discord](https://img.shields.io/discord/583845970433933312.svg)](https://discord.gg/5u3f3up)Auditing base logic component for [EdenJS](https://github.com/edenjs-cli)
`@edenjs/audit` automatically tracks all model specific actions in the system. By including any model you want to track in config `@edenjs/audit` will track every `update`, `remove`, and `create`, and if possible who/what was changed.
## Setup
### Install
```
npm i --save @edenjs/audit
```### Configure
```js
config.audit = {
models : ['user', 'product'], // which models do we want to track
};
```## Models
### `Audit` _[Usage](https://github.com/eden-js/audit/blob/master/bundles/audit/models/audit.js)_
Audit model consists of a single tracking item, each instance in the database corresponds to a single `update`, `remove`, or `create` of any tracked model.
#### Example
```js
const Audit = model('audit');
```## Hooks
### `audit.check` _[Usage](https://github.com/eden-js/audit/blob/master/bundles/audit/daemons/audit.js#L60)_
Auditing logic allows us to hook and prevent creation of an audit item, or alter the updates/by fields.
#### Example
```js
this.eden.pre('audit.check', (data) => {
// extract variables
const { by, updates, subject } = data;// prevent audit creation by setting prevent : true
data.prevent = true;
});
```