Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

moleculer-decorators

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moleculer-decorators - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

25

dist/index.js

@@ -5,2 +5,3 @@ "use strict";

const blacklist = ['created', 'started', 'stopped', 'actions', 'methods', 'events'];
const blacklist2 = ['metadata', 'settings', 'mixins', 'name', 'version'].concat(blacklist);
const defaultServiceOptions = {

@@ -37,2 +38,3 @@ constructOverride: true

const proto = target.prototype;
const vars = [];
Object.getOwnPropertyNames(proto).forEach(function (key) {

@@ -45,4 +47,22 @@ if (key === 'constructor') {

base[key] = Object.getOwnPropertyDescriptor(ServiceClass, key).value;
if (blacklist2.indexOf(key) === -1) {
vars[key] = Object.getOwnPropertyDescriptor(ServiceClass, key).value;
}
}
});
const bypass = Object.defineProperty, obj = {};
bypass(obj, 'created', {
value: function created() {
for (let key in vars) {
this[key] = vars[key];
}
if (!_.isNil(Object.getOwnPropertyDescriptor(proto, 'created'))) {
Object.getOwnPropertyDescriptor(proto, 'created').value.call(this);
}
},
writable: true,
enumerable: true,
configurable: true
});
base['created'] = obj.created;
}

@@ -52,4 +72,7 @@ return;

const descriptor = Object.getOwnPropertyDescriptor(proto, key);
if (key === 'created' || key === 'started' || key === 'stopped') {
if (key === 'created' && !_options.constructOverride) {
base[key] = descriptor.value;
}
if (key === 'started' || key === 'stopped') {
base[key] = descriptor.value;
return;

@@ -56,0 +79,0 @@ }

2

package.json
{
"name": "moleculer-decorators",
"version": "1.0.10",
"version": "1.0.11",
"description": "decorators for moleculer",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -5,2 +5,3 @@ import { ServiceSchema, Action, ActionHandler } from 'moleculer';

const blacklist = ['created', 'started', 'stopped', 'actions', 'methods', 'events'];
const blacklist2 = ['metadata', 'settings', 'mixins', 'name', 'version'].concat(blacklist);
const defaultServiceOptions: Options = {

@@ -55,2 +56,3 @@ constructOverride: true

const proto = target.prototype;
const vars = [];
Object.getOwnPropertyNames(proto).forEach(function (key) {

@@ -64,6 +66,32 @@ if (key === 'constructor') {

base[key] = Object.getOwnPropertyDescriptor(ServiceClass, key)!.value
if (blacklist2.indexOf(key) === -1) { // Needed, otherwize if the service is used as a mixin, these variables will overwrite the toplevel's
vars[key] = Object.getOwnPropertyDescriptor(ServiceClass, key)!.value
}
}
});
/* Insane hack below :D
* It's needed since moleculer don't transfer all defined props in the
* schema to the actual service, so we have to do it.
*/
const bypass: any = Object.defineProperty, // typescript fix
obj: any = {}; // placeholder
bypass(obj, 'created', {
value: function created() {
for (let key in vars) {
this[key] = vars[key];
}
if (!_.isNil(Object.getOwnPropertyDescriptor(proto, 'created'))) {
Object.getOwnPropertyDescriptor(proto, 'created').value.call(this);
}
},
writable: true,
enumerable: true,
configurable: true
});
base['created'] = obj.created;
}
return;

@@ -74,4 +102,8 @@ }

if (key === 'created' || key === 'started' || key === 'stopped') {
if (key === 'created' && !_options.constructOverride) {
base[key] = descriptor.value;
}
if (key === 'started' || key === 'stopped') {
base[key] = descriptor.value;
return;

@@ -78,0 +110,0 @@ }

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