https://github.com/eden-js/audit
https://github.com/eden-js/audit
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/eden-js/audit
- Owner: eden-js
- Created: 2019-02-12T01:10:47.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-05-31T17:31:34.000Z (about 4 years ago)
- Last Synced: 2025-01-26T18:17:27.218Z (4 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
[](https://travis-ci.com/eden-js/audit)
[](https://github.com/eden-js/audit/issues)
[](https://github.com/eden-js/audit)
[](https://github.com/eden-js/audit)
[](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;
});
```