grpc-promise2
Advanced tools
Comparing version 2.2.0 to 2.3.0
const requestTypes = require('./request-types/request-types'); | ||
const promisifyAll = function (client, options, requestMiddleware) { | ||
const promisifyAll = function (client, options, requestMiddleware, responseMiddleware) { | ||
Object.keys(Object.getPrototypeOf(client)).forEach(function (functionName) { | ||
@@ -28,3 +28,7 @@ const originalFunction = client[functionName]; | ||
client[functionName] = requestTypes[genericFunctionName](client, originalFunction, options, requestMiddleware); | ||
if (genericFunctionName === 'makeUnaryRequest') { | ||
client[functionName] = requestTypes[genericFunctionName](client, originalFunction, options, requestMiddleware, responseMiddleware); | ||
} else { | ||
client[functionName] = requestTypes[genericFunctionName](client, originalFunction, options); | ||
} | ||
}); | ||
@@ -31,0 +35,0 @@ }; |
@@ -5,3 +5,3 @@ const mergeMetadata = require('../metadata'); | ||
constructor (client, original_function, options = {}, requestMiddleware = null) { | ||
constructor (client, original_function, options = {}, requestMiddleware = null, responseMiddleware = null) { | ||
if (options == null) options = {}; | ||
@@ -15,2 +15,3 @@ this.client = client; | ||
}; | ||
this.responseMiddleware = responseMiddleware; | ||
} | ||
@@ -29,2 +30,3 @@ | ||
const origFunc = this.original_function; | ||
const responseMiddleware = this.responseMiddleware; | ||
@@ -36,2 +38,6 @@ const next = function (client, content, meta) { | ||
function (error, response) { | ||
if (typeof responseMiddleware === 'function') { | ||
responseMiddleware(error, response); | ||
} | ||
if (error) { | ||
@@ -52,6 +58,6 @@ reject(error); | ||
const makeUnaryRequest = function (client, originalFunction, options, requestMiddleware) { | ||
const makeUnaryRequest = function (client, originalFunction, options, requestMiddleware, responseMiddleware) { | ||
// console.log(options); | ||
return function () { | ||
return new UnaryRequest(client, originalFunction, options, requestMiddleware); | ||
return new UnaryRequest(client, originalFunction, options, requestMiddleware, responseMiddleware); | ||
}; | ||
@@ -58,0 +64,0 @@ }; |
{ | ||
"name": "grpc-promise2", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "This is a fork of grpc-promise with extended metadata support. GRPC promisify module for all Request/Response types: standard and stream", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
53703
1039