onjs 2.1.1 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,63 @@
1
+ name: GitHub Actions
2
+ run-name: ${{ github.actor }} is testing and building changes
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches:
7
+ - master
8
+ pull_request:
9
+ release:
10
+ types: [published]
11
+
12
+ permissions:
13
+ contents: read
14
+ pull-requests: read
15
+
16
+ concurrency:
17
+ group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
18
+ cancel-in-progress: true
19
+
20
+ jobs:
21
+ test-and-build:
22
+ runs-on: ubuntu-latest
23
+ container: node:16-bullseye
24
+ services:
25
+ redis:
26
+ image: redis:alpine
27
+ ports:
28
+ - 19379:6379
29
+ options: >-
30
+ --health-cmd "redis-cli ping"
31
+ --health-interval 10s
32
+ --health-timeout 5s
33
+ --health-retries 5
34
+ rabbitmq:
35
+ image: rabbitmq:alpine
36
+ ports:
37
+ - 5672:5672
38
+ env:
39
+ RABBITMQ_ERLANG_COOKIE: SWQOKODSQALRPCLNMEQG
40
+ RABBITMQ_DEFAULT_USER: rabbitmq
41
+ RABBITMQ_DEFAULT_PASS: rabbitmq
42
+ RABBITMQ_DEFAULT_VHOST: /
43
+
44
+ steps:
45
+ - run: echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
46
+ - name: Check out repository code
47
+ uses: actions/checkout@v3
48
+ - run: echo "The ${{ github.repository }} repository has been cloned to the runner."
49
+ - run: echo "The workflow is now ready to test your code on the runner."
50
+ - name: Installing dependencies
51
+ run: npm install
52
+
53
+ - name: Testing
54
+ run: npm test
55
+ - run: echo "Job's status is ${{ job.status }}."
56
+ - uses: actions/setup-node@v3
57
+ with:
58
+ node-version: '16.x'
59
+ registry-url: 'https://registry.npmjs.org'
60
+ - name: Publishing to NPM
61
+ run: npm publish
62
+ env:
63
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/README.md CHANGED
@@ -142,7 +142,7 @@ var options = {
142
142
 
143
143
  var mqOptions = {
144
144
  exchange_name: 'onjs_test',
145
- url: 'amqp://rabbitmq:rabbitmq@localhost:35672/'
145
+ url: 'amqp://rabbitmq:rabbitmq@localhost:5672/'
146
146
  }
147
147
 
148
148
  var mq = new MQ(mqOptions)
@@ -1,16 +1,21 @@
1
1
  #!/bin/bash
2
2
 
3
3
  RABBIT_CONTAINER_NAME=onjs_rabbit_test
4
- RABBIT_CONTAINER_PORT1=34369
5
- RABBIT_CONTAINER_PORT2=35671
6
- RABBIT_CONTAINER_PORT3=35672
7
- RABBIT_CONTAINER_PORT4=46872
4
+ RABBIT_CONTAINER_PORT=5672
5
+
8
6
 
9
7
  REDIS_CONTAINER_NAME=onjs_redis_test
10
8
  REDIS_CONTAINER_PORT=19379
11
9
 
12
10
  function createRabbitContainer() {
13
- id=$(docker run -d --name ${RABBIT_CONTAINER_NAME} -p ${RABBIT_CONTAINER_PORT1}:4369 -p ${RABBIT_CONTAINER_PORT2}:5671 -p ${RABBIT_CONTAINER_PORT3}:5672 -p ${RABBIT_CONTAINER_PORT4}:25672 -e RABBITMQ_ERLANG_COOKIE=SWQOKODSQALRPCLNMEQG -e RABBITMQ_DEFAULT_USER=rabbitmq -e RABBITMQ_DEFAULT_PASS=rabbitmq -e RABBITMQ_DEFAULT_VHOST=/ --hostname rabbitmq rabbitmq:alpine)
11
+ id=$(docker run -d --name ${RABBIT_CONTAINER_NAME} \
12
+ -p 5672 \
13
+ -e RABBITMQ_ERLANG_COOKIE=SWQOKODSQALRPCLNMEQG \
14
+ -e RABBITMQ_DEFAULT_USER=rabbitmq \
15
+ -e RABBITMQ_DEFAULT_PASS=rabbitmq \
16
+ -e RABBITMQ_DEFAULT_VHOST=/ \
17
+ --hostname rabbitmq \
18
+ rabbitmq:alpine)
14
19
  echo $id
15
20
  }
16
21
 
package/lib/on.js CHANGED
@@ -1,6 +1,5 @@
1
1
  var RedisQueue = require('bull');
2
2
  var _ = require('lodash')
3
- var Q = require('q')
4
3
  var EventEmitter = require('events')
5
4
  var utils = require('./utils')
6
5
  var hasProperties = utils.hasProperties
@@ -261,7 +260,7 @@ class On extends EventEmitter {
261
260
  _onTaskReceived (task, data) {
262
261
  this._eventLog('info', task.eventName, 'Executing task callback for task')
263
262
 
264
- return Q.allSettled(task.actions.map((action) => {
263
+ return Promise.allSettled(task.actions.map((action) => {
265
264
  return action.call(task, data)
266
265
  }))
267
266
  .then((results) => {
@@ -520,7 +519,7 @@ class On extends EventEmitter {
520
519
  this._eventLog('info', event.eventName, `Processing redis event ${event.eventName} and executing callback`)
521
520
  this._eventLog('info', event.eventName, `Calling event callback`)
522
521
 
523
- return Q.allSettled(event.actions.map((action) => {
522
+ return Promise.allSettled(event.actions.map((action) => {
524
523
  return action.call(event, data, next)
525
524
  }))
526
525
  .then((results) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onjs",
3
- "version": "2.1.1",
3
+ "version": "2.2.1",
4
4
  "description": "On.js is an event library based on RabbitMQ that helps you control events on a microservices arquitecture",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -24,14 +24,12 @@
24
24
  },
25
25
  "engineStrict": true,
26
26
  "devDependencies": {
27
- "rabbitmq-lib": "^2.1.0",
27
+ "rabbitmq-lib": "^2.2.0",
28
28
  "should": "^13.1.3"
29
29
  },
30
30
  "dependencies": {
31
- "amqplib": "^0.5.2",
32
- "bull": "^3.0.0-rc.4",
33
- "mocha": "^5.2.0",
34
- "q": "^1.5.0",
35
- "uuid": "^3.1.0"
31
+ "amqplib": "^0.10.3",
32
+ "bull": "^3.29.3",
33
+ "mocha": "^5.2.0"
36
34
  }
37
35
  }
@@ -14,11 +14,11 @@ describe('Queue', function () {
14
14
  var config = {
15
15
  mq: {
16
16
  exchange_name: 'onjs_test',
17
- url: 'amqp://rabbitmq:rabbitmq@localhost:35672/',
17
+ url: 'amqp://rabbitmq:rabbitmq@rabbitmq:5672/',
18
18
  },
19
19
  redis: {
20
20
  port: REDIS_PORT,
21
- host: '127.0.0.1'
21
+ host: 'redis'
22
22
  }
23
23
  }
24
24
 
@@ -13,11 +13,11 @@ describe('RPC', function () {
13
13
  var config = {
14
14
  mq: {
15
15
  exchange_name: 'onjs_test',
16
- url: 'amqp://rabbitmq:rabbitmq@localhost:35672/',
16
+ url: 'amqp://rabbitmq:rabbitmq@rabbitmq:5672/',
17
17
  },
18
18
  redis: {
19
19
  port: REDIS_PORT,
20
- host: '127.0.0.1'
20
+ host: 'redis'
21
21
  }
22
22
  }
23
23
 
@@ -17,11 +17,11 @@ describe('On.js', function () {
17
17
  var config = {
18
18
  mq: {
19
19
  exchange_name: 'onjs_test',
20
- url: 'amqp://rabbitmq:rabbitmq@localhost:35672/',
20
+ url: 'amqp://rabbitmq:rabbitmq@rabbitmq:5672/',
21
21
  },
22
22
  redis: {
23
23
  port: REDIS_PORT,
24
- host: '127.0.0.1'
24
+ host: 'redis'
25
25
  }
26
26
  }
27
27
 
@@ -12,11 +12,11 @@ describe('Topics', function () {
12
12
  var config = {
13
13
  mq: {
14
14
  exchange_name: 'onjs_test',
15
- url: 'amqp://rabbitmq:rabbitmq@localhost:35672/',
15
+ url: 'amqp://rabbitmq:rabbitmq@rabbitmq:5672/',
16
16
  },
17
17
  redis: {
18
18
  port: REDIS_PORT,
19
- host: '127.0.0.1'
19
+ host: 'redis'
20
20
  }
21
21
  }
22
22