telefonicaid / fiware-pep-steelskin

Telefonica's implementation of the FIWARE PEP GE
GNU Affero General Public License v3.0
0 stars 0 forks source link

Remove dependency on deprecated domain module #528

Closed rg2011 closed 9 months ago

rg2011 commented 9 months ago

Fixes issue https://github.com/telefonicaid/fiware-pep-steelskin/issues/498

domain module is deprecated since node 10 (https://nodejs.org/docs/latest-v10.x/api/domain.html). It is used to improve logging, by storing information related to the request in a per-request domain. The callback provided to function getContext of logops package queries that domain to retrieve request information.

This PR replaces the global logger with a per-request instance, stored in req.logger. This instance is created by a middleware that runs early in the chain, and populates the per-request logger instance with the same information that used to be in the context.

All the middleware and handlers are also refactored to use the per-request logger instead of the global one, so this PR can dispose of the logger.getContext callback and the domain dependency.

rg2011 commented 9 months ago

Probably obsoletes #500 and #503