Socket
Socket
Sign inDemoInstall

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.22 to 1.1.0

15

dist/index.d.ts

@@ -1,15 +0,2 @@

import { ServiceSchema, Action, ActionHandler, LoggerInstance, ServiceMethods, ServiceEvents, Actions, ServiceSettingSchema, GenericObject, ServiceBroker, ServiceEvent, ServiceEventHandler } from 'moleculer';
export declare class BaseSchema {
[x: string]: any;
logger: LoggerInstance;
name: string;
broker: ServiceBroker;
version: string | number;
settings: ServiceSettingSchema;
metadata: GenericObject;
mixins: Array<ServiceSchema>;
actions: Actions;
methods: ServiceMethods;
events: ServiceEvents;
}
import { ServiceSchema, Action, ActionHandler, ServiceEvent, ServiceEventHandler } from 'moleculer';
export interface Options extends Partial<ServiceSchema> {

@@ -16,0 +3,0 @@ name?: string;

12

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const moleculer_1 = require("moleculer");
const _ = require("lodash");

@@ -20,5 +19,2 @@ const blacklist = [

};
class BaseSchema {
}
exports.BaseSchema = BaseSchema;
function Method(target, key, descriptor) {

@@ -50,2 +46,3 @@ (target.methods || (target.methods = {}))[key] = descriptor.value;

exports.Action = Action;
const mockServiceBroker = new Object({ Promise });
function Service(options = {}) {

@@ -71,3 +68,3 @@ return function (constructor) {

if (_options.constructOverride) {
const ServiceClass = new parentService.constructor(new moleculer_1.ServiceBroker());
const ServiceClass = new parentService.constructor(mockServiceBroker);
Object.getOwnPropertyNames(ServiceClass).forEach(function (key) {

@@ -124,4 +121,5 @@ if (blacklist.indexOf(key) === -1 &&

return class extends parentService.constructor {
constructor(broker) {
super(broker, base);
constructor(broker, schema) {
super(broker, schema);
this.parseServiceSchema(base);
}

@@ -128,0 +126,0 @@ };

{
"name": "moleculer-decorators",
"version": "1.0.22",
"version": "1.1.0",
"description": "decorators for moleculer",

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

@@ -36,25 +36,2 @@ import {

/**
* Don't use this anymore! You need a valid ServiceFactory class instance to extend from.
* Using BaseSchema will result in an error
*
* @deprecated
*/
export class BaseSchema {
[x: string]: any;
logger: LoggerInstance;
name: string;
broker: ServiceBroker;
version: string | number;
settings: ServiceSettingSchema;
metadata: GenericObject;
mixins: Array<ServiceSchema>;
actions: Actions;
methods: ServiceMethods;
events: ServiceEvents;
}
export interface Options extends Partial<ServiceSchema> {

@@ -110,2 +87,5 @@ name?: string;

// Instead of using moleculer's ServiceBroker, we will fake the broker class to pass it to service constructor
const mockServiceBroker = new Object({ Promise });
export function Service(options: Options = {}): Function {

@@ -138,3 +118,3 @@ return function(constructor: Function

// Override properties defined in @Service
const ServiceClass = new parentService.constructor(new ServiceBroker()); // initializing from Moleculer ServiceFactory class
const ServiceClass = new parentService.constructor(mockServiceBroker);

@@ -223,4 +203,6 @@ Object.getOwnPropertyNames(ServiceClass).forEach(function(key) {

return class extends parentService.constructor {
constructor(broker) {
super(broker, base);
constructor(broker, schema) {
super(broker, schema);
this.parseServiceSchema(base);
}

@@ -227,0 +209,0 @@ }

@@ -6,5 +6,7 @@ import { ServiceBroker } from 'moleculer';

describe('Moleculer', () => {
const broker = new ServiceBroker();
const broker = new ServiceBroker({ logLevel: 'warn' });
const customizedBroker = new ServiceBroker({
ServiceFactory: CustomService
// @ts-ignore
ServiceFactory: CustomService,
logLevel: 'warn'
});

@@ -30,5 +32,8 @@

it('should pass auth', async () => {
return request(apiService.server).get('/getTest/getModel/5')
await request(apiService.server).get('/getTest/getModel/5')
.set('Authorization', VALID_TOKEN)
.expect(200);
// close HTTP service to release the port
broker.destroyService(apiService);
});

@@ -35,0 +40,0 @@ });

@@ -1,2 +0,3 @@

import { BaseSchema, Service } from '../../src';
import { Service } from '../../src';
const moleculer = require('moleculer');
const DbMixin = require('moleculer-db');

@@ -7,3 +8,3 @@

})
class DbService extends BaseSchema {
class DbService extends moleculer.Service {
public connected: boolean = false;

@@ -10,0 +11,0 @@

Sorry, the diff of this file is not supported yet

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