puzpuzpuz / cls-rtracer

Request Tracer - CLS-based request id generation for Express, Fastify, Koa and Hapi, batteries included
MIT License
311 stars 24 forks source link

Migrate to Fastify lifecycle hook instead of middleware #10

Closed puzpuzpuz closed 4 years ago

puzpuzpuz commented 5 years ago

See https://github.com/fastify/fastify/pull/1731#pullrequestreview-258368824

SimenB commented 4 years ago

Upcoming fastify v3 will not ship with support for connect style middleware out of the box, would be wonderful if this module would be compatible out of the box 👍

puzpuzpuz commented 4 years ago

@SimenB thanks for the heads up! I'll include this one into v2.1.0.

SimenB commented 4 years ago

Thanks! If you want inspiration: https://github.com/kibertoad/fastify-request-context/blob/c6007084dbe65125d4f01855fa7cb25bed930a12/lib/requestContextPlugin.js

SimenB commented 4 years ago

Another link - fastify has a concept of request ID already. I'm not sure if it's possible to hook into it, but making them play nice together would be wonderful - see https://www.fastify.io/docs/v3.0.x/Server/#requestidheader and the 2 entries below it

(Caveat: our current app is using Express, but I'm looking into migrating to Fastify. So I don't have much knowledge about how this ties together)

puzpuzpuz commented 4 years ago

@SimenB thanks for sharing these links. I've implemented the plugin, as well as an option for Fastify request id integration. See #30