Mali request ID metadata middleware sources request ID into context
npm install @malijs/requestidMali request ID metadata middleware sources request ID into context


| Param | Type | Description |
| --- | --- | --- |
| options | Options | |
| options.name | String | Optional name of the metadata object property. Default: 'requestId' |
| options.target | String \| Boolean | Optional name of the ctx property to set request id into. If not provided it is equal to options.name. |
| options.generator | function | Synchronous function to generate the request id if not present. Has to return a string. Default: uuid library. |
Example
``js
const rid = require('@malijs/requestid')
app.use(rid())
app.use('myFn', async (ctx, next) => {
console.log(ctx.requestId) // request ID from metadata
await next()
})
``
Apache-2.0