-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from denlap007/v4
v4
- Loading branch information
Showing
15 changed files
with
699 additions
and
647 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"node": true | ||
"node": "current" | ||
} | ||
} | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
language: node_js | ||
node_js: | ||
- 12 | ||
- 14 | ||
before_install: | ||
- npm install coveralls --save-dev | ||
script: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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** |
Oops, something went wrong.