Skip to content

Commit

Permalink
deprecate server.app
Browse files Browse the repository at this point in the history
  • Loading branch information
felixheck committed Jul 14, 2017
1 parent 9170d85 commit 27df8c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ laabr.format('onPostStart', 'server.env');
The `event` is allowed to be `onPostStart`, `onPostStop`, `response`, `request-error` and `log`. The events are analog to the [hapi-pino ⇗](https://github.com/pinojs/hapi-pino) ones.

## `laabr.cid`
The methods listed below are exposed via `server.cid` and `server.app.cid` as well.
The methods listed below are exposed via `server.cid` as well.

- `laabr.cid.get()`:<br/>[`correlator.getId()`](https://github.com/toboid/correlation-id#getid)
- `laabr.cid.with([<string> id,] <Function> work)`:<br/> [`correlator.withId()`](https://github.com/toboid/correlation-id#withidid-work)
Expand Down
7 changes: 6 additions & 1 deletion src/correlator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const correlator = require('correlation-id')
const deprecate = require('depd')('correlator')
const validator = require('./validator')

/**
Expand Down Expand Up @@ -45,8 +46,12 @@ function validateOption (options) {
*/
function expose (laabr, server) {
laabr.cid = getCorrelator()
server.app.cid = laabr.cid
server.decorate('server', 'cid', laabr.cid)
server.app.cid = {}

Object.keys(laabr.cid).forEach(fn => {
server.app.cid[fn] = deprecate.function(laabr.cid[fn])
})
}

/**
Expand Down

0 comments on commit 27df8c4

Please sign in to comment.