@appolo/bus
Advanced tools
Comparing version 8.0.9 to 8.0.10
@@ -10,3 +10,2 @@ "use strict"; | ||
const decorators_1 = require("./src/common/decorators"); | ||
const _ = require("lodash"); | ||
let BusModule = BusModule_1 = class BusModule extends engine_1.Module { | ||
@@ -25,10 +24,10 @@ static for(options) { | ||
let requestMeta = this.app.tree.parent.discovery.findAllReflectData(decorators_1.RequestSymbol); | ||
_.forEach(publisherMeta, (item => this._createPublishers(item))); | ||
_.forEach(requestMeta, (item => this._createRequests(item))); | ||
(publisherMeta || []).forEach(item => this._createPublishers(item)); | ||
(requestMeta || []).forEach(item => this._createRequests(item)); | ||
} | ||
_createPublishers(item) { | ||
_.forEach(item.metaData, publisher => this._createPublisher(item.fn, publisher)); | ||
Object.keys(item.metaData || {}).forEach(key => this._createPublisher(item.fn, item.metaData[key])); | ||
} | ||
_createRequests(item) { | ||
_.forEach(item.metaData, publisher => this._createRequest(item.fn, publisher)); | ||
Object.keys(item.metaData || {}).forEach(key => this._createRequest(item.fn, item.metaData[key])); | ||
} | ||
@@ -35,0 +34,0 @@ async _createPublisher(fn, item) { |
@@ -1,2 +0,2 @@ | ||
import {module, Module,IModuleParams} from '@appolo/engine'; | ||
import {module, Module, IModuleParams} from '@appolo/engine'; | ||
import {IOptions} from "./src/common/IOptions"; | ||
@@ -10,3 +10,2 @@ | ||
import {Reflector} from '@appolo/utils'; | ||
import * as _ from 'lodash'; | ||
@@ -17,5 +16,4 @@ @module() | ||
public static for(options?: IOptions): IModuleParams { | ||
return {type:BusModule,options}; | ||
return {type: BusModule, options}; | ||
} | ||
@@ -36,4 +34,4 @@ | ||
_.forEach(publisherMeta, (item => this._createPublishers(item))); | ||
_.forEach(requestMeta, (item => this._createRequests(item))); | ||
(publisherMeta || []).forEach(item => this._createPublishers(item)); | ||
(requestMeta || []).forEach(item => this._createRequests(item)); | ||
@@ -44,3 +42,3 @@ } | ||
_.forEach(item.metaData, publisher => this._createPublisher(item.fn, publisher)); | ||
Object.keys(item.metaData || {}).forEach(key => this._createPublisher(item.fn, item.metaData[key])); | ||
} | ||
@@ -50,3 +48,3 @@ | ||
_.forEach(item.metaData, publisher => this._createRequest(item.fn, publisher)); | ||
Object.keys(item.metaData || {}).forEach(key => this._createRequest(item.fn, item.metaData[key])); | ||
} | ||
@@ -53,0 +51,0 @@ |
import {Define, inject, singleton} from '@appolo/inject' | ||
import {IApp} from '@appolo/engine' | ||
import * as _ from "lodash"; | ||
import {IHandler, IHandlerMetadata, IHandlerMetadataOptions, IHandlerProperties} from "../common/interfaces"; | ||
@@ -5,0 +4,0 @@ import {TopologyManager} from "../topology/topologyManager"; |
import {define, singleton} from '@appolo/inject' | ||
import { HandlerSymbol} from "../common/decorators"; | ||
import * as _ from "lodash"; | ||
import {BaseHandlersManager} from "./baseHandlersManager"; | ||
@@ -5,0 +4,0 @@ import {TopologyManager} from "../topology/topologyManager"; |
@@ -6,3 +6,3 @@ "use strict"; | ||
const inject_1 = require("@appolo/inject"); | ||
const _ = require("lodash"); | ||
const utils_1 = require("@appolo/utils"); | ||
let MessageManager = class MessageManager { | ||
@@ -44,3 +44,3 @@ constructor() { | ||
if (handlers.length) { | ||
await Promise.all(_.map(handlers, handler => this._callHandler(msg, handler))); | ||
await utils_1.Promises.map(handlers || [], handler => this._callHandler(msg, handler)); | ||
} | ||
@@ -47,0 +47,0 @@ msg.ack(); |
@@ -7,3 +7,3 @@ import {define, inject, Injector, singleton} from "@appolo/inject"; | ||
import {ILogger} from "@appolo/logger/index"; | ||
import * as _ from "lodash"; | ||
import {Promises} from "@appolo/utils"; | ||
import {BusProvider} from "../bus/busProvider"; | ||
@@ -77,3 +77,3 @@ import {RequestError} from "../common/requestError"; | ||
if (handlers.length) { | ||
await Promise.all(_.map(handlers, handler => this._callHandler(msg, handler))); | ||
await Promises.map(handlers || [], handler => this._callHandler(msg, handler)); | ||
} | ||
@@ -80,0 +80,0 @@ |
@@ -6,3 +6,2 @@ "use strict"; | ||
const inject_1 = require("@appolo/inject"); | ||
const _ = require("lodash"); | ||
const url = require("url"); | ||
@@ -52,5 +51,5 @@ const defaults_1 = require("../common/defaults"); | ||
if (this.moduleOptions.queue) { | ||
queues.unshift(_.isString(this.moduleOptions.queue) ? { name: this.moduleOptions.queue } : this.moduleOptions.queue); | ||
queues.unshift(utils_1.Strings.isString(this.moduleOptions.queue) ? { name: this.moduleOptions.queue } : this.moduleOptions.queue); | ||
} | ||
queues = _.map(queues, queue => Object.assign({}, defaults_1.QueueDefaults, queue, { name: this.appendEnv(queue.name) })); | ||
queues = queues.map(queue => Object.assign({}, defaults_1.QueueDefaults, queue, { name: this.appendEnv(queue.name) })); | ||
return queues; | ||
@@ -61,5 +60,5 @@ } | ||
if (this.moduleOptions.requestQueue) { | ||
requestQueues.unshift(_.isString(this.moduleOptions.requestQueue) ? { name: this.moduleOptions.requestQueue } : this.moduleOptions.requestQueue); | ||
requestQueues.unshift(utils_1.Strings.isString(this.moduleOptions.requestQueue) ? { name: this.moduleOptions.requestQueue } : this.moduleOptions.requestQueue); | ||
} | ||
requestQueues = _.map(requestQueues, queue => Object.assign({}, defaults_1.RequestQueueDefaults, queue, { name: this.appendEnv(queue.name) })); | ||
requestQueues = requestQueues.map(queue => Object.assign({}, defaults_1.RequestQueueDefaults, queue, { name: this.appendEnv(queue.name) })); | ||
return requestQueues; | ||
@@ -70,3 +69,3 @@ } | ||
if (this.moduleOptions.replyQueue) { | ||
replyQueue = _.isString(this.moduleOptions.replyQueue) ? { name: this.moduleOptions.replyQueue } : this.moduleOptions.replyQueue; | ||
replyQueue = utils_1.Strings.isString(this.moduleOptions.replyQueue) ? { name: this.moduleOptions.replyQueue } : this.moduleOptions.replyQueue; | ||
replyQueue = Object.assign({}, defaults_1.ReplyQueueDefaults, replyQueue, { name: this.appendEnv(replyQueue.name) }); | ||
@@ -79,5 +78,5 @@ } | ||
if (this.moduleOptions.exchange) { | ||
exchanges.unshift(_.isString(this.moduleOptions.exchange) ? { name: this.moduleOptions.exchange } : this.moduleOptions.exchange); | ||
exchanges.unshift(utils_1.Strings.isString(this.moduleOptions.exchange) ? { name: this.moduleOptions.exchange } : this.moduleOptions.exchange); | ||
} | ||
exchanges = _.map(exchanges, exchange => Object.assign({}, defaults_1.ExchangeDefaults, exchange, { name: this.appendEnv(exchange.name) })); | ||
exchanges = exchanges.map(exchange => Object.assign({}, defaults_1.ExchangeDefaults, exchange, { name: this.appendEnv(exchange.name) })); | ||
return exchanges; | ||
@@ -87,3 +86,3 @@ } | ||
let connection = this.moduleOptions.connection; | ||
if (_.isString(this.moduleOptions.connection)) { | ||
if (utils_1.Strings.isString(this.moduleOptions.connection)) { | ||
connection = { uri: this.moduleOptions.connection }; | ||
@@ -113,3 +112,3 @@ } | ||
let handlers = messageHandlers.concat(replyHandlers); | ||
_.forEach(handlers, handler => { | ||
handlers.forEach(handler => { | ||
bindings.push({ | ||
@@ -133,8 +132,9 @@ exchange: handler.exchange, | ||
let exported = this.app.tree.parent.discovery.findAllReflectData(symbol); | ||
_.forEach(exported, (item) => this.addHandler(item.fn, item.define, item.metaData, manager, defaultQueue)); | ||
exported.forEach((item) => this.addHandler(item.fn, item.define, item.metaData, manager, defaultQueue)); | ||
} | ||
addHandler(fn, define, metaData, manager, defaultQueue) { | ||
let output = []; | ||
_.forEach(metaData, handler => { | ||
_.forEach(handler.events, item => { | ||
Object.keys(metaData || {}).forEach(key => { | ||
let handler = metaData[key]; | ||
(handler.events || []).forEach(item => { | ||
let dto = this._addHandler(item.eventName, item.options, defaultQueue, manager, define, handler.propertyKey); | ||
@@ -141,0 +141,0 @@ output.push(dto); |
import {define, inject, singleton, Util, Define} from "@appolo/inject"; | ||
import {IEnv, App, IApp} from "@appolo/engine"; | ||
import {IOptions} from "../common/IOptions"; | ||
import * as _ from "lodash"; | ||
import {HandlersManager} from "../handlers/handlersManager"; | ||
@@ -19,3 +18,3 @@ import {RepliesManager} from "../handlers/repliesManager"; | ||
import {HandlerSymbol, ReplySymbol, RequestSymbol} from "../common/decorators"; | ||
import {Reflector} from "@appolo/utils"; | ||
import {Reflector, Strings} from "@appolo/utils"; | ||
@@ -93,6 +92,6 @@ @define() | ||
if (this.moduleOptions.queue) { | ||
queues.unshift(_.isString(this.moduleOptions.queue) ? {name: this.moduleOptions.queue} : this.moduleOptions.queue); | ||
queues.unshift(Strings.isString(this.moduleOptions.queue) ? {name: this.moduleOptions.queue} : this.moduleOptions.queue); | ||
} | ||
queues = _.map(queues, queue => Object.assign({}, QueueDefaults, queue, {name: this.appendEnv(queue.name)})); | ||
queues = queues.map(queue => Object.assign({}, QueueDefaults, queue, {name: this.appendEnv(queue.name)})); | ||
@@ -107,6 +106,6 @@ return queues; | ||
if (this.moduleOptions.requestQueue) { | ||
requestQueues.unshift(_.isString(this.moduleOptions.requestQueue) ? {name: this.moduleOptions.requestQueue} : this.moduleOptions.requestQueue); | ||
requestQueues.unshift(Strings.isString(this.moduleOptions.requestQueue) ? {name: this.moduleOptions.requestQueue} : this.moduleOptions.requestQueue); | ||
} | ||
requestQueues = _.map(requestQueues, queue => Object.assign({}, RequestQueueDefaults, queue, {name: this.appendEnv(queue.name)})); | ||
requestQueues = requestQueues.map(queue => Object.assign({}, RequestQueueDefaults, queue, {name: this.appendEnv(queue.name)})); | ||
@@ -121,3 +120,3 @@ return requestQueues; | ||
if (this.moduleOptions.replyQueue) { | ||
replyQueue = _.isString(this.moduleOptions.replyQueue) ? {name: this.moduleOptions.replyQueue} : this.moduleOptions.replyQueue; | ||
replyQueue = Strings.isString(this.moduleOptions.replyQueue) ? {name: this.moduleOptions.replyQueue} : this.moduleOptions.replyQueue; | ||
@@ -135,7 +134,7 @@ replyQueue = Object.assign({}, ReplyQueueDefaults, replyQueue, {name: this.appendEnv(replyQueue.name)}) | ||
if (this.moduleOptions.exchange) { | ||
exchanges.unshift(_.isString(this.moduleOptions.exchange) ? {name: this.moduleOptions.exchange} : this.moduleOptions.exchange); | ||
exchanges.unshift(Strings.isString(this.moduleOptions.exchange) ? {name: this.moduleOptions.exchange} : this.moduleOptions.exchange); | ||
} | ||
exchanges = _.map(exchanges, exchange => Object.assign({}, ExchangeDefaults, exchange, {name: this.appendEnv(exchange.name)})); | ||
exchanges = exchanges.map(exchange => Object.assign({}, ExchangeDefaults, exchange, {name: this.appendEnv(exchange.name)})); | ||
@@ -148,3 +147,3 @@ return exchanges; | ||
if (_.isString(this.moduleOptions.connection)) { | ||
if (Strings.isString(this.moduleOptions.connection)) { | ||
connection = {uri: this.moduleOptions.connection} | ||
@@ -181,3 +180,3 @@ } | ||
_.forEach(handlers, handler => { | ||
handlers.forEach(handler => { | ||
bindings.push({ | ||
@@ -215,3 +214,3 @@ exchange: handler.exchange, | ||
_.forEach(exported, (item) => this.addHandler(item.fn, item.define, item.metaData, manager, defaultQueue)) | ||
exported.forEach((item) => this.addHandler(item.fn, item.define, item.metaData, manager, defaultQueue)) | ||
} | ||
@@ -223,5 +222,6 @@ | ||
_.forEach(metaData, handler => { | ||
Object.keys(metaData || {}).forEach(key => { | ||
let handler = metaData[key]; | ||
_.forEach(handler.events, item => { | ||
(handler.events || []).forEach(item => { | ||
@@ -261,3 +261,2 @@ let dto = this._addHandler(item.eventName, item.options, defaultQueue, manager, define, handler.propertyKey) | ||
manager.register(eventName, options, define, propertyKey); | ||
@@ -264,0 +263,0 @@ |
{ | ||
"name": "@appolo/bus", | ||
"version": "8.0.9", | ||
"version": "8.0.10", | ||
"description": "appolo bus module", | ||
@@ -19,4 +19,3 @@ "publishConfig": { | ||
"appolo-rabbit": "^8.0.2", | ||
"@appolo/utils": "^8.0.5", | ||
"lodash": "^4.17.20" | ||
"@appolo/utils": "^8.0.5" | ||
}, | ||
@@ -26,3 +25,2 @@ "devDependencies": { | ||
"@types/chai": "^4.2.14", | ||
"@types/lodash": "^4.14.165", | ||
"@types/mocha": "^8.2.0", | ||
@@ -29,0 +27,0 @@ "@types/node": "^14.14.11", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
81890
5
11
1829
+ Addedaxios@1.7.8(transitive)
- Removedlodash@^4.17.20
- Removedaxios@1.7.7(transitive)
- Removedlodash@4.17.21(transitive)