Skip to content

Commit

Permalink
prevent unsupported operation call
Browse files Browse the repository at this point in the history
  • Loading branch information
吉田 尚弘 committed Aug 30, 2016
1 parent a7e3f8a commit 6127574
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libs/fetcher.js
Expand Up @@ -6,6 +6,7 @@
var OP_READ = 'read';
var OP_CREATE = 'create';
var OP_UPDATE = 'update';
var OP_DELETE = 'delete';
var GET = 'GET';
var qs = require('querystring');
var debug = require('debug')('Fetchr');
Expand Down Expand Up @@ -223,7 +224,7 @@ function executeRequest (request, resolve, reject) {
var service;
try {
service = Fetcher.getService(request.resource);
if (!service[op]) {
if ([OP_CREATE,OP_READ,OP_UPDATE,OP_DELETE].indexOf(op) < 0 || !service[op]) {
throw new Error('operation: ' + op + ' is undefined on service: ' + request.resource);
}
service[op].apply(service, args);
Expand Down

0 comments on commit 6127574

Please sign in to comment.