Closed draperunner closed 2 years ago
Question, is this a breaking change for TS? can I interchangeably use a previous method with signature DynamicMetaFunction
in the new property of base logger of type DynamicMetaFunctionError
?
I think if you just made the request and response fields optional in the interface, you wouldn't need a separate DynamicMetaFunctionError and DynamicLevelFunctionError (i.e. you could use the same for the error handler as the regular request handler.
And yes @bithavoc I think his changes would be TS compatible (i.e. they would not be a breaking change) but I think it's worth having tests that prove that.
The logger middleware alters the response object, so that its type is not exactly like the pure Express request. This leads to errors if you're using
res.responseTime
orres.body
in your owndynamicMeta
. I have created a typeExpressWinstonResponse
which includes these two fields.I have also made the
DynamicMetaFunction
use this new ExpressWinstonResponse type. But I had to split it, as the error middleware's response does not have a responseTime or body. So the type fordynamicMeta
is different for the error middleware and the standard middleware.I have also replace
object
withRecord<string, any>
as the return type fordynamicMeta
. This is because ifobject
is used, TypeScript does not allow you to add properties to the returned object.