aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/node/src/server.js
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2017-01-30 16:52:17 -0800
committerGravatar murgatroid99 <mlumish@google.com>2017-01-30 16:52:17 -0800
commita171538b92994ccabf55c353f2a136db5563455c (patch)
tree40673d01125ac3df523335b599e70da89f3af382 /src/node/src/server.js
parent87b8195ebaefa6cc47a89631022a7849ebfcc45a (diff)
Node: Validate arguments to addService, fix a couple of minor issues
Diffstat (limited to 'src/node/src/server.js')
-rw-r--r--src/node/src/server.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/node/src/server.js b/src/node/src/server.js
index da9c6b2d7f..d501e76c67 100644
--- a/src/node/src/server.js
+++ b/src/node/src/server.js
@@ -728,11 +728,17 @@ var defaultHandler = {
* method implementation for the provided service.
*/
Server.prototype.addService = function(service, implementation) {
+ if (!_.isObjectLike(service) || !_.isObjectLike(implementation)) {
+ throw new Error('addService requires two objects as arguments');
+ }
+ if (_.keys(service).length === 0) {
+ throw new Error('Cannot add an empty service to a server');
+ }
if (this.started) {
throw new Error('Can\'t add a service to a started server.');
}
var self = this;
- _.each(service, function(attrs, name) {
+ _.forOwn(service, function(attrs, name) {
var method_type;
if (attrs.requestStream) {
if (attrs.responseStream) {