1.0.1 • Published 4 years ago
fastify-request-id v1.0.1
Fastify Request Id 
An alternative request id plugin for fastify
Install
> npm install --save fastify-request-idUsage
const Fastify = require('fastify')
const requestId = require('fastify-request-id')
const fastify = Fastify()
fastify.register(requestId())
fastify.get('/', (request, reply) => {
console.log(request.reqId) // osUlY5xlcT
reply.send({ hello: 'world' })
// Response headers => x-request-id: osUlY5xlcT
})API
requestId([, pluginOpts])
getId(Function) - a custum funtion that return string (id). Default - random nano id with 10 chartersisAddToResponse(Boolean) - add response header with request id. Default - trueheaderName(String) - ifisAddToResponseis set to true, you can choose what will be the header name. Default -x-request-id