You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.2 KiB
35 lines
1.2 KiB
'use strict'
|
|
|
|
var errSerializer = require('./lib/err')
|
|
var reqSerializers = require('./lib/req')
|
|
var resSerializers = require('./lib/res')
|
|
|
|
module.exports = {
|
|
err: errSerializer,
|
|
mapHttpRequest: reqSerializers.mapHttpRequest,
|
|
mapHttpResponse: resSerializers.mapHttpResponse,
|
|
req: reqSerializers.reqSerializer,
|
|
res: resSerializers.resSerializer,
|
|
|
|
wrapErrorSerializer: function wrapErrorSerializer (customSerializer) {
|
|
if (customSerializer === errSerializer) return customSerializer
|
|
return function wrapErrSerializer (err) {
|
|
return customSerializer(errSerializer(err))
|
|
}
|
|
},
|
|
|
|
wrapRequestSerializer: function wrapRequestSerializer (customSerializer) {
|
|
if (customSerializer === reqSerializers.reqSerializer) return customSerializer
|
|
return function wrappedReqSerializer (req) {
|
|
return customSerializer(reqSerializers.reqSerializer(req))
|
|
}
|
|
},
|
|
|
|
wrapResponseSerializer: function wrapResponseSerializer (customSerializer) {
|
|
if (customSerializer === resSerializers.resSerializer) return customSerializer
|
|
return function wrappedResSerializer (res) {
|
|
return customSerializer(resSerializers.resSerializer(res))
|
|
}
|
|
}
|
|
}
|