Skip to content

Commit

Permalink
Merge 38cb554 into 5a8cb01
Browse files Browse the repository at this point in the history
  • Loading branch information
denlap007 committed Dec 26, 2021
2 parents 5a8cb01 + 38cb554 commit aaec33e
Show file tree
Hide file tree
Showing 14 changed files with 698 additions and 646 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"@babel/preset-env",
{
"targets": {
"node": true
"node": "current"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
node-version: 14
- run: npm install
- run: npm test
- uses: JS-DevTools/npm-publish@v1
Expand Down
61 changes: 61 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Changelog

## Breaking changes v4

### Node.js
**Dropped** support for Node.js **12**. Minimum Node.js version is now **14**

### API changes
#### Registration Options
- auditAuthOnly -> removed (can be filtered with isAuditable, check example below)
- auditGetRequests -> removed (can be filtered with isAuditable, check example below)
- showErrorsOnStdErr -> renamed to **debug** (false by default)
- isAuditable -> invoked with **request** as parameter (arity 1) to handle all cases (audits all by default, check example below for filtering)
- getEntity -> renamed to **setEntity**. Returns by default the endpoint path
- cacheEnabled -> renamed to isCacheEnabled

Example using **isAuditable** (auditAuthOnly, auditGetRequests cases and path filtering)

```js
await server.register({
plugin: require("hapi-audit-rest"),
options: {
isAuditable: ({ auth: { isAuthenticated }, method, url: { pathname } }) => {
// do not audit unauthenticated requests
if (!isAuthenticated) {
return false
}

// do not audit GET requests
if (method === "get") {
return false
}

// do not audit requests when path does not start from /api
if (!pathname.startsWith("/api")) {
return false
}

// return true to audit all other cases
return true
}
},
});
```

Example using **setEntity** option:
```js
await server.register({
plugin: require("hapi-audit-rest"),
options: {
// use the standard pattern of an api i.e. /api/v1.0/users, to refine the entity name
// will have 'entity: users' in audit log
setEntity: (path) => path.split("/")[3],
}
},
});
```


#### Route Options
- getPath -> renamed to **setInjectedPath**
128 changes: 91 additions & 37 deletions README.md

Large diffs are not rendered by default.

0 comments on commit aaec33e

Please sign in to comment.