New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ee-soa-service

Package Overview
Dependencies
Maintainers
2
Versions
176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ee-soa-service - npm Package Compare versions

Comparing version 0.2.21 to 0.2.22

45

lib/DefaultService.js

@@ -13,3 +13,4 @@

, argv = require('ee-argv')
, debug = argv.has('dev-service');
, debug = argv.has('dev-service')
, debugService = argv.has('debug-service');

@@ -194,2 +195,4 @@ module.exports = new Class({

if (debugService) log.info('[DefaultService] incoming request on '+[this.name, req.getCollection(), req.getActionName()].join('.')+' ...');
if(this._hasController(collection)) {

@@ -203,2 +206,4 @@ var action = req.getActionName() || req.getAction();

if (debugService) log.info('[DefaultService] the permissions management is '+(this.permissionManager ? 'enabled' : 'disabled')+' ...');
// check permissions if the permissions manager

@@ -214,2 +219,4 @@ // was loaded

if (debugService) log.info('[DefaultService] '+[this.name, req.getCollection(), req.getActionName()].join('.')+' - access was granted!');
// store the permissions object on the request

@@ -221,4 +228,9 @@ req.permissions = permission;

}
else this._handleResponse(new Error('You [the user(s) '+permission.getUsers().map(function(u) {return u.id}).join(', ')+' and the service(s) '+permission.getServices().map(function(s) {return s.identifier}).join(', ')+'] are not allowed to access the controller «'+collection+'», action «'+(this._permissionMap[action] || action)+'» on the service «'+this.name+'»!'), {}, req, callback, SOAResponse.statusCodes.ACCESS_UNAUTHORIZED);
else {
if (debugService) log.info('[DefaultService] '+[this.name, req.getCollection(), req.getActionName()].join('.')+' - access was denied!');
callback(new Error('You [the user(s) '+permission.getUsers().map(function(u) {return u.id}).join(', ')+' and the service(s) '+permission.getServices().map(function(s) {return s.identifier}).join(', ')+'] are not allowed to access the controller «'+collection+'», action «'+(this._permissionMap[action] || action)+'» on the service «'+this.name+'»!'), {}, SOAResponse.statusCodes.ACCESS_UNAUTHORIZED);
}
}.bind(this)).catch(function(err) {
if (debugService) log.info('[DefaultService] '+[this.name, req.getCollection(), req.getActionName()].join('.')+' - the permission mnagement returned an error: '+err);

@@ -245,5 +257,17 @@ // failed to load the permissions

// it's not exactly known why this works like this works :/
if (this[controllerAction]) this[controllerAction](collection, req, callback);
if (this[controllerAction]) {
if (debugService) log.info('[DefaultService] '+[this.name, req.getCollection(), req.getActionName()].join('.')+' - calling service method «'+controllerAction+'» ...');
this[controllerAction](collection, req, callback);
}
else if (this._controllerCollection[collection][action]) {
if (debugService) log.info('[DefaultService] '+[this.name, req.getCollection(), req.getActionName()].join('.')+' - calling controller ...');
this._controllerCollection[collection][action](req, function(err, result, status, headers) {
if (debugService) {
if (err) log.warn('[DefaultService] '+[this.name, req.getCollection(), req.getActionName()].join('.')+' - got an error response from the controller: '+err);
else if (status) log.info('[DefaultService] '+[this.name, req.getCollection(), req.getActionName()].join('.')+' - controller responded with the status «'+status+'» ...');
else log.info('[DefaultService] '+[this.name, req.getCollection(), req.getActionName()].join('.')+' - controller responded with the default status ...');
}
this._handleResponse(err, result, req, callback, status, headers);

@@ -261,6 +285,13 @@ }.bind(this));

if (debugService) log.info('[DefaultService] Outgoing request for '+[this.name, req.getCollection(), req.getActionName()].join('.')+' ...');
// add my own accesstoken if the feature is loaded
if (this.accessToken && req.accessTokens) req.accessTokens.push(this.accessToken);
if (this.accessToken && req.accessTokens) {
if (debugService) log.debug('[DefaultService] Added my service token ...');
req.accessTokens.push(this.accessToken);
}
var res = new SOAResponse();

@@ -271,2 +302,4 @@ res.on('end', function(status, result) {

if (debugService) log.info('[DefaultService] Outgoing request for '+[this.name, req.getCollection(), req.getActionName()].join('.')+' responded with the status «'+status+'» ...');
callback(err, result); //TODO: write status and check, give callback direct to on end, or write error on res

@@ -276,5 +309,9 @@ }.bind(this));

if(this._hasController(collection)) {
if (debugService) log.debug('[DefaultService] Hanbdling request internally ...');
this.request(req, res);
}
else {
if (debugService) log.debug('[DefaultService] Emitting request ...');
this.emit('request', req, res);

@@ -281,0 +318,0 @@ }

2

package.json

@@ -5,3 +5,3 @@ {

, "keywords" : ["ee", "soa", "service"]
, "version" : "0.2.21"
, "version" : "0.2.22"
, "author": {

@@ -8,0 +8,0 @@ "name" : "Tobias Kneubuehler"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc