Skip to content

Commit

Permalink
docs(chore): readme changes for audit-log (#919)
Browse files Browse the repository at this point in the history
gh-855

Co-authored-by: akshatdubeysf <[email protected]>
  • Loading branch information
yeshamavani and akshatdubeysf authored Sep 17, 2022
1 parent 3e4ec07 commit 4479754
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions services/audit-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

![npm (prod) dependency version (scoped)](https://img.shields.io/npm/dependency-version/@sourceloop/audit-service/@loopback/core)

A LoopBack microservice used for auditing user actions. It uses [@sourceloop/audit-log](https://www.npmjs.com/package/@sourceloop/audit-log) to store the logs to a datasource. This service provides REST endpoints to perform CRUD operations for the audit logs.
## Overview

A LoopBack microservice used for auditing user actions. All the user actions like insert, update and delete can be audited. It uses [@sourceloop/audit-log](https://www.npmjs.com/package/@sourceloop/audit-log) as a base which provides the same functionality but through a repository mixin. A repository mixin logs all the actions by default. So when we use a repository mixin we have less control over the customization that can be done. So in case where we want to audit only in certain scenario or for a particular case this service can be used. This service exposes APIs to insert and read the audited data so that we have a free hand.

## Installation

Expand All @@ -20,8 +22,6 @@ npm i @sourceloop/audit-service

## Usage

- Create a new Loopback4 Application (If you don't have one already)
`lb4 testapp`
- Install the audit service
`npm i @sourceloop/audit-service`
- Set the [environment variables](#environment-variables).
Expand All @@ -42,6 +42,19 @@ npm i @sourceloop/audit-service
The logs in this service can either be created through the REST endpoint, or through a repository mixin provided with the [@sourceloop/audit-log](https://www.npmjs.com/package/@sourceloop/audit-log) npm module. This mixin, by default, creates logs for all the inbuilt actions done through the extended repository.
You can read more about how to use this package [here](https://github.com/sourcefuse/loopback4-audit-log#readme).

All the different types of action that are logged are

```ts
export declare enum Action {
INSERT_ONE = 'INSERT_ONE',
INSERT_MANY = 'INSERT_MANY',
UPDATE_ONE = 'UPDATE_ONE',
UPDATE_MANY = 'UPDATE_MANY',
DELETE_ONE = 'DELETE_ONE',
DELETE_MANY = 'DELETE_MANY',
}
```

### Environment Variables

Do not forget to set Environment variables. The examples below show a common configuration for a PostgreSQL Database running locally.
Expand Down

0 comments on commit 4479754

Please sign in to comment.