@autofleet/rabbit 1.4.2 → 1.5.0-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.
package/.eslintrc.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "root": true,
3
+ "env": {
4
+ "node": true,
5
+ "jest": true
6
+ },
7
+ "extends": [
8
+ "airbnb-base",
9
+ "plugin:@typescript-eslint/recommended"
10
+ ],
11
+ "rules": {
12
+ "import/extensions": [
13
+ "error",
14
+ "ignorePackages",
15
+ {
16
+ "js": "never",
17
+ "jsx": "never",
18
+ "ts": "never",
19
+ "tsx": "never"
20
+ }
21
+ ],
22
+ "@typescript-eslint/no-unused-vars": ["error"],
23
+ "@typescript-eslint/no-var-requires": ["off"],
24
+ "@typescript-eslint/camelcase": ["off"],
25
+ "max-len": ["off"],
26
+ "@typescript-eslint/explicit-function-return-type": ["off"]
27
+ },
28
+ "overrides": [
29
+ {
30
+ // enable the rule specifically for TypeScript files
31
+ "files": ["src/**.js", "src/**.ts"],
32
+ "rules": {
33
+ "@typescript-eslint/explicit-function-return-type": ["off"],
34
+ "@typescript-eslint/no-var-requires": ["off"],
35
+ "@typescript-eslint/camelcase": ["off"]
36
+ }
37
+ }
38
+ ],
39
+ "parser": "@typescript-eslint/parser",
40
+ "parserOptions": {
41
+ "project": "./tsconfig.json",
42
+ "sourceType": "module"
43
+ },
44
+ "ignorePatterns": ["dist/*", "node_modules/", "jest.config.js", "migrations/*", "newrelic.js"],
45
+ "plugins": ["@typescript-eslint"],
46
+ "settings": {
47
+ "import/extensions": [
48
+ "error",
49
+ "ignorePackages",
50
+ {
51
+ "js": "never",
52
+ "jsx": "never",
53
+ "ts": "never",
54
+ "tsx": "never"
55
+ }
56
+ ],
57
+ "import/parsers": {
58
+ "@typescript-eslint/parser": [".ts",".tsx"]
59
+ },
60
+ "import/resolver": {
61
+ "node": {
62
+ "extensions": [".js",".jsx",".ts",".tsx", ".json"]
63
+ }
64
+ }
65
+ }
66
+ }
package/dist/example.js CHANGED
@@ -1,22 +1,33 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  const index_1 = require("./index");
4
- const init = async () => {
13
+ // process.env.RABBITMQ_SERVICE_HOST="34.76.223.229:5672";
14
+ const init = () => __awaiter(void 0, void 0, void 0, function* () {
5
15
  const rabbit = new index_1.default();
6
- await rabbit.consumeFromExchange('test-q2', 'test-e', (msg, ack) => {
16
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
17
+ yield rabbit.consumeFromExchange('test-q2', 'test-e', (msg, ack) => {
7
18
  console.log('msg2', msg.content);
8
19
  // ack(msg);
9
20
  });
10
- await rabbit.consumeFromExchange('test-q', 'test-e', (msg, ack) => {
21
+ yield rabbit.consumeFromExchange('test-q', 'test-e', (msg, ack) => {
11
22
  console.log('msg', msg.content);
12
23
  ack(msg);
13
24
  });
14
- await rabbit.publish('test-e', 'hey');
15
- await rabbit.publish('test-e', 'hey1');
16
- await rabbit.consume('test-q-2', (msg, ack) => {
25
+ yield rabbit.publish('test-e', 'hey');
26
+ yield rabbit.publish('test-e', 'hey1');
27
+ yield rabbit.consume('test-q-2', (msg, ack) => {
17
28
  console.log('msg-q', msg.content);
18
29
  ack(msg);
19
30
  });
20
- await rabbit.sendToQueue('test-q-2', 'hey-q');
21
- };
31
+ yield rabbit.sendToQueue('test-q-2', 'hey-q');
32
+ });
22
33
  init();
package/dist/index.d.ts CHANGED
@@ -7,10 +7,13 @@ interface ExchangesCache {
7
7
  declare class RabbitMq {
8
8
  static parseMsg(msg: any): any;
9
9
  static validateName(type: string, name: string): void;
10
+ PUBLISH_TIMEOUT: number;
11
+ PUBLISH_ERROR_MSG: string;
12
+ DISCONNECT_MSG: string;
10
13
  channel: ChannelWrapper | null;
11
14
  connection: AmqpConnectionManager | null;
12
15
  em: EventEmitter;
13
- creatingConnection: Boolean;
16
+ creatingConnection: boolean;
14
17
  exchanges: ExchangesCache;
15
18
  constructor();
16
19
  ack: (msg: any) => Promise<void>;
@@ -21,7 +24,7 @@ declare class RabbitMq {
21
24
  assertQueue(queue: string, options?: any): Promise<void>;
22
25
  consume(queue: string, callback: (msg: any, ack: Function, nack: Function) => any, options?: any): Promise<void>;
23
26
  consumeFromExchange(queue: string, exchange: string, callback: (msg: any, ack: Function, nack: Function) => any, options?: any): Promise<void>;
24
- publish(exchange: string, content: any): Promise<void>;
27
+ publish(exchange: string, content: any): Promise<unknown>;
25
28
  sendToQueue(queue: string, content: any): Promise<void>;
26
29
  }
27
30
  export default RabbitMq;
package/dist/index.js CHANGED
@@ -1,32 +1,46 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ // eslint-disable-next-line max-classes-per-file
13
+ const bluebird = require("bluebird");
3
14
  const amqp_connection_manager_1 = require("amqp-connection-manager");
4
15
  const events_1 = require("events");
5
- class RabbitError extends Error {
6
- }
16
+ const rabbitError_1 = require("./rabbitError");
7
17
  const connectionCreatedConst = 'connectionCreated';
8
18
  class RabbitMq {
9
19
  constructor() {
10
- this.ack = async (msg) => {
20
+ this.PUBLISH_TIMEOUT = Number(process.env.RABBITMQ_PUBLISH_TIMEOUT) || 60000;
21
+ this.PUBLISH_ERROR_MSG = `rabbit: publish timeout(${this.PUBLISH_TIMEOUT}ms) has pass, exchange: `;
22
+ this.DISCONNECT_MSG = 'rabbit: connection disconnect';
23
+ this.ack = (msg) => __awaiter(this, void 0, void 0, function* () {
11
24
  if (this.channel) {
12
- await this.channel.ack(msg);
25
+ yield this.channel.ack(msg);
13
26
  }
14
- };
15
- this.nack = (queue) => async (msg, retries) => {
27
+ });
28
+ this.nack = (queue) => (msg, retries) => __awaiter(this, void 0, void 0, function* () {
16
29
  if (this.channel) {
17
30
  if (!msg.content['x-retry-count'] || msg.content['x-retry-count'] <= retries) {
31
+ // eslint-disable-next-line no-param-reassign
18
32
  msg.content['x-retry-count'] = msg.content['x-retry-count'] ? msg.content['x-retry-count'] + 1 : 1;
19
- await this.sendToQueue(queue, msg.content);
33
+ yield this.sendToQueue(queue, msg.content);
20
34
  }
21
35
  else {
22
36
  const deadQueue = `${queue}-dead`;
23
- await this.assertQueue(deadQueue);
24
- await this.sendToQueue(deadQueue, msg.content);
37
+ yield this.assertQueue(deadQueue);
38
+ yield this.sendToQueue(deadQueue, msg.content);
25
39
  }
26
- await this.channel.ack(msg);
40
+ yield this.channel.ack(msg);
27
41
  }
28
- };
29
- this.em = new events_1.EventEmitter;
42
+ });
43
+ this.em = new events_1.EventEmitter();
30
44
  this.channel = null;
31
45
  this.connection = null;
32
46
  this.creatingConnection = false;
@@ -38,105 +52,132 @@ class RabbitMq {
38
52
  try {
39
53
  content = JSON.parse(content);
40
54
  }
41
- catch (e) { }
42
- return Object.assign({}, msg, { content });
55
+ catch (e) { } // eslint-disable-line no-empty
56
+ return Object.assign(Object.assign({}, msg), { content });
43
57
  }
44
58
  static validateName(type, name) {
45
59
  if (!name || name === '') {
46
- throw new RabbitError(`error while using ${type} with no name`);
60
+ throw new rabbitError_1.default(`error while using ${type} with no name`);
47
61
  }
48
62
  }
49
- async getConnection() {
50
- return new Promise(async (resolve) => {
51
- if (this.creatingConnection) {
52
- this.em.on(connectionCreatedConst, resolve);
53
- return;
54
- }
55
- if (this.connection !== null) {
56
- return this.connection;
57
- }
58
- this.creatingConnection = true;
59
- let host = process.env.RABBITMQ_SERVICE_HOST || '35.240.13.28';
60
- let connection = await amqp_connection_manager_1.connect([`amqp://${host}`]);
61
- this.connection = connection;
62
- this.creatingConnection = false;
63
- this.em.emit(connectionCreatedConst, connection);
64
- resolve(connection);
63
+ getConnection() {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ // eslint-disable-next-line no-async-promise-executor
66
+ return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
67
+ if (this.creatingConnection) {
68
+ this.em.on(connectionCreatedConst, resolve);
69
+ return;
70
+ }
71
+ if (this.connection !== null) {
72
+ // eslint-disable-next-line consistent-return
73
+ return this.connection;
74
+ }
75
+ this.creatingConnection = true;
76
+ const host = process.env.RABBITMQ_SERVICE_HOST || '';
77
+ const connection = yield amqp_connection_manager_1.connect([`amqp://${host}`]);
78
+ this.connection = connection;
79
+ this.connection.on('disconnect', ({ err }) => console.error(`${this.DISCONNECT_MSG}${err && ` - ${err}`}`));
80
+ this.creatingConnection = false;
81
+ this.em.emit(connectionCreatedConst, connection);
82
+ resolve(connection);
83
+ }));
65
84
  });
66
85
  }
67
- async assertChannel() {
68
- return new Promise(async (resolve, reject) => {
69
- if (this.channel) {
70
- return resolve(this.channel);
71
- }
72
- let connection = await this.getConnection();
73
- try {
74
- if (this.channel === null) {
75
- this.channel = connection.createChannel({});
86
+ assertChannel() {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ // eslint-disable-next-line no-async-promise-executor,consistent-return
89
+ return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
90
+ if (this.channel) {
91
+ return resolve(this.channel);
76
92
  }
77
- resolve(this.channel);
78
- }
79
- catch (e) {
80
- reject(e);
81
- }
93
+ const connection = yield this.getConnection();
94
+ try {
95
+ if (this.channel === null) {
96
+ this.channel = connection.createChannel({});
97
+ }
98
+ resolve(this.channel);
99
+ }
100
+ catch (e) {
101
+ reject(e);
102
+ }
103
+ }));
82
104
  });
83
105
  }
84
- async assertExchange(exchangeName, options) {
85
- const channel = await this.assertChannel();
86
- if (this.exchanges[exchangeName]) {
87
- return this.exchanges[exchangeName];
88
- }
89
- return channel.addSetup(async (c) => {
90
- const exchange = await c.assertExchange(exchangeName, 'fanout');
91
- this.exchanges[exchangeName] = exchange;
92
- return exchange;
106
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
107
+ assertExchange(exchangeName, options) {
108
+ return __awaiter(this, void 0, void 0, function* () {
109
+ const channel = yield this.assertChannel();
110
+ if (this.exchanges[exchangeName]) {
111
+ return this.exchanges[exchangeName];
112
+ }
113
+ return channel.addSetup((c) => __awaiter(this, void 0, void 0, function* () {
114
+ const exchange = yield c.assertExchange(exchangeName, 'fanout');
115
+ this.exchanges[exchangeName] = exchange;
116
+ return exchange;
117
+ }));
93
118
  });
94
119
  }
95
- async assertQueue(queue, options) {
96
- RabbitMq.validateName('queue', queue);
97
- const channel = await this.assertChannel();
98
- return channel.addSetup((c) => c.assertQueue(queue));
120
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
121
+ assertQueue(queue, options) {
122
+ return __awaiter(this, void 0, void 0, function* () {
123
+ RabbitMq.validateName('queue', queue);
124
+ const channel = yield this.assertChannel();
125
+ return channel.addSetup((c) => c.assertQueue(queue));
126
+ });
99
127
  }
100
- async consume(queue, callback, options) {
101
- RabbitMq.validateName('queue', queue);
102
- const { limit } = (options && options.limit) ? options : { limit: 1 };
103
- const channel = await this.assertChannel();
104
- await this.assertQueue(queue);
105
- return channel.addSetup(async (c) => {
106
- await c.prefetch(limit, true);
107
- return Promise.all([
108
- c.consume(queue, (msg) => callback(RabbitMq.parseMsg(msg), this.ack, this.nack(queue))),
109
- ]);
128
+ // eslint-disable-next-line @typescript-eslint/ban-types
129
+ consume(queue, callback, options) {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ RabbitMq.validateName('queue', queue);
132
+ const { limit } = (options && options.limit) ? options : { limit: 1 };
133
+ const channel = yield this.assertChannel();
134
+ yield this.assertQueue(queue);
135
+ return channel.addSetup((c) => __awaiter(this, void 0, void 0, function* () {
136
+ yield c.prefetch(limit, true);
137
+ return Promise.all([
138
+ c.consume(queue, (msg) => callback(RabbitMq.parseMsg(msg), this.ack, this.nack(queue))),
139
+ ]);
140
+ }));
110
141
  });
111
142
  }
112
- async consumeFromExchange(queue, exchange, callback, options) {
113
- RabbitMq.validateName('queue', queue);
114
- RabbitMq.validateName('exchange', exchange);
115
- const { limit } = (options && options.limit) ? options : { limit: 1 };
116
- const channel = await this.assertChannel();
117
- await Promise.all([
118
- this.assertExchange(exchange),
119
- this.assertQueue(queue),
120
- ]);
121
- return channel.addSetup(async (c) => {
122
- await c.prefetch(limit, true);
123
- return Promise.all([
124
- c.bindQueue(queue, exchange, ''),
125
- c.consume(queue, (msg) => callback(RabbitMq.parseMsg(msg), this.ack, this.nack(queue))),
143
+ // eslint-disable-next-line @typescript-eslint/ban-types
144
+ consumeFromExchange(queue, exchange, callback, options) {
145
+ return __awaiter(this, void 0, void 0, function* () {
146
+ RabbitMq.validateName('queue', queue);
147
+ RabbitMq.validateName('exchange', exchange);
148
+ const { limit } = (options && options.limit) ? options : { limit: 1 };
149
+ const channel = yield this.assertChannel();
150
+ yield Promise.all([
151
+ this.assertExchange(exchange),
152
+ this.assertQueue(queue),
126
153
  ]);
154
+ return channel.addSetup((c) => __awaiter(this, void 0, void 0, function* () {
155
+ yield c.prefetch(limit, true);
156
+ return Promise.all([
157
+ c.bindQueue(queue, exchange, ''),
158
+ c.consume(queue, (msg) => callback(RabbitMq.parseMsg(msg), this.ack, this.nack(queue))),
159
+ ]);
160
+ }));
127
161
  });
128
162
  }
129
- async publish(exchange, content) {
130
- RabbitMq.validateName('exchange', exchange);
131
- const channel = await this.assertChannel();
132
- await this.assertExchange(exchange);
133
- return channel.publish(exchange, '', Buffer.from(JSON.stringify(content)));
163
+ publish(exchange, content) {
164
+ return __awaiter(this, void 0, void 0, function* () {
165
+ RabbitMq.validateName('exchange', exchange);
166
+ const channel = yield this.assertChannel();
167
+ yield this.assertExchange(exchange);
168
+ return new bluebird.Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
169
+ yield channel.publish(exchange, '', Buffer.from(JSON.stringify(content)));
170
+ return resolve();
171
+ })).timeout(this.PUBLISH_TIMEOUT, `${this.PUBLISH_ERROR_MSG}${exchange}`);
172
+ });
134
173
  }
135
- async sendToQueue(queue, content) {
136
- RabbitMq.validateName('queue', queue);
137
- const channel = await this.assertChannel();
138
- await this.assertQueue(queue);
139
- return channel.sendToQueue(queue, Buffer.from(JSON.stringify(content)));
174
+ sendToQueue(queue, content) {
175
+ return __awaiter(this, void 0, void 0, function* () {
176
+ RabbitMq.validateName('queue', queue);
177
+ const channel = yield this.assertChannel();
178
+ yield this.assertQueue(queue);
179
+ return channel.sendToQueue(queue, Buffer.from(JSON.stringify(content)));
180
+ });
140
181
  }
141
182
  }
142
183
  exports.default = RabbitMq;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const index_1 = require("./index");
13
+ // import RabbitError from './rabbitError';
14
+ jest.setTimeout(120000);
15
+ const rabbit = new index_1.default();
16
+ const delay = () => new Promise((resolve) => setTimeout(() => resolve(), 500));
17
+ describe('RabbitMQ', () => {
18
+ it('check exchange', () => __awaiter(void 0, void 0, void 0, function* () {
19
+ const callback = (msg, ack) => {
20
+ expect(msg.content).toEqual('hey');
21
+ ack(msg);
22
+ };
23
+ const mockFn = jest.fn(callback);
24
+ yield rabbit.consumeFromExchange('test-q2', 'test-e', mockFn);
25
+ yield rabbit.publish('test-e', 'hey');
26
+ yield delay();
27
+ expect(mockFn).toBeCalled();
28
+ }));
29
+ it('check queue', () => __awaiter(void 0, void 0, void 0, function* () {
30
+ const callback = (msg, ack) => {
31
+ expect(msg.content).toEqual('hey-q');
32
+ ack(msg);
33
+ };
34
+ const mockFn = jest.fn(callback);
35
+ yield rabbit.consume('test-q-2', mockFn);
36
+ yield rabbit.sendToQueue('test-q-2', 'hey-q');
37
+ yield delay();
38
+ expect(mockFn).toBeCalled();
39
+ }));
40
+ it('cant publish to unknown exchange', () => __awaiter(void 0, void 0, void 0, function* () {
41
+ let err;
42
+ try {
43
+ yield rabbit.publish('', 'hey');
44
+ }
45
+ catch (e) {
46
+ err = e;
47
+ }
48
+ expect(err).toBeDefined();
49
+ }));
50
+ it('cant publish due timeout', () => __awaiter(void 0, void 0, void 0, function* () {
51
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
52
+ // @ts-ignore
53
+ process.env.RABBITMQ_PUBLISH_TIMEOUT = 1;
54
+ const rabbit2 = new index_1.default();
55
+ let err;
56
+ try {
57
+ yield rabbit2.publish('test-e', 'hey');
58
+ }
59
+ catch (e) {
60
+ err = e;
61
+ }
62
+ expect(err).toBeDefined();
63
+ }));
64
+ });
package/dist/mock.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import 'jest';
2
2
  declare class RabbitMq {
3
- ack: jest.Mock<{}>;
4
- nack: jest.Mock<{}>;
5
- assertChannel: jest.Mock<{}>;
6
- assertExchange: jest.Mock<{}>;
7
- assertQueue: jest.Mock<{}>;
8
- consume: jest.Mock<{}>;
9
- consumeFromExchange: jest.Mock<{}>;
10
- publish: jest.Mock<{}>;
11
- sendToQueue: jest.Mock<{}>;
3
+ ack: jest.Mock<any, any>;
4
+ nack: jest.Mock<any, any>;
5
+ assertChannel: jest.Mock<any, any>;
6
+ assertExchange: jest.Mock<any, any>;
7
+ assertQueue: jest.Mock<any, any>;
8
+ consume: jest.Mock<any, any>;
9
+ consumeFromExchange: jest.Mock<any, any>;
10
+ publish: jest.Mock<any, any>;
11
+ sendToQueue: jest.Mock<any, any>;
12
12
  }
13
13
  export default RabbitMq;
@@ -0,0 +1,3 @@
1
+ export default class RabbitError extends Error {
2
+ constructor(message: string);
3
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class RabbitError extends Error {
4
+ constructor(message) {
5
+ super(message);
6
+ this.name = 'RabbitError';
7
+ }
8
+ }
9
+ exports.default = RabbitError;
package/jest.config.js ADDED
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ testEnvironment: 'node',
3
+ roots: ['<rootDir>/src'],
4
+ transform: {
5
+ '^.+\\.tsx?$': 'ts-jest',
6
+ },
7
+ testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(tsx?$|jsx?$)',
8
+ moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
9
+ coverageThreshold: {
10
+ global: {
11
+ lines: 75,
12
+ },
13
+ },
14
+ }
package/package.json CHANGED
@@ -1,25 +1,35 @@
1
1
  {
2
2
  "name": "@autofleet/rabbit",
3
- "version": "1.4.2",
3
+ "version": "1.5.0-1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "start": "ts-node src/index.ts",
8
8
  "example": "ts-node src/example.ts",
9
9
  "prepublish": "tsc",
10
+ "linter": "./node_modules/.bin/eslint .",
11
+ "test": "jest --forceExit",
12
+ "test-local": "RABBITMQ_SERVICE_HOST=34.76.223.229:5672 jest --forceExit",
13
+ "coverage": "jest --coverage --forceExit --runInBand && rm -rf ./coverage",
10
14
  "dev": "nodemon"
11
15
  },
12
16
  "dependencies": {
17
+ "@types/jest": "^23.0.0",
13
18
  "@types/amqp-connection-manager": "^2.0.2",
14
19
  "@types/amqplib": "^0.5.9",
15
- "@types/jest": "^23.3.10",
16
20
  "amqp-connection-manager": "^3.2.1",
17
21
  "amqplib": "^0.6.0",
18
- "jest": "^23.6.0"
22
+ "bluebird": "^3.7.2",
23
+ "jest": "^25.3.0"
19
24
  },
20
25
  "devDependencies": {
21
- "ts-node": "^7.0.1",
22
- "typescript": "^3.2.1"
26
+ "@typescript-eslint/eslint-plugin": "^4.8.1",
27
+ "eslint": "^7.13.0",
28
+ "eslint-config-airbnb-typescript": "^12.0.0",
29
+ "eslint-plugin-import": "^2.22.1",
30
+ "ts-jest": "^25.4.0",
31
+ "ts-node": "^8.6.2",
32
+ "typescript": "^3.8.3"
23
33
  },
24
34
  "author": "",
25
35
  "license": "ISC"
package/src/example.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  import RabbitMq from './index';
2
2
 
3
+ // process.env.RABBITMQ_SERVICE_HOST="34.76.223.229:5672";
4
+
3
5
  const init = async () => {
4
6
  const rabbit = new RabbitMq();
7
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
8
  await rabbit.consumeFromExchange('test-q2', 'test-e', (msg, ack) => {
6
9
  console.log('msg2', msg.content);
7
10
  // ack(msg);
@@ -11,15 +14,14 @@ const init = async () => {
11
14
  console.log('msg', msg.content);
12
15
  ack(msg);
13
16
  });
14
- await rabbit.publish('test-e', 'hey')
15
- await rabbit.publish('test-e', 'hey1')
16
-
17
+ await rabbit.publish('test-e', 'hey');
18
+ await rabbit.publish('test-e', 'hey1');
17
19
 
18
20
  await rabbit.consume('test-q-2', (msg, ack) => {
19
21
  console.log('msg-q', msg.content);
20
22
  ack(msg);
21
23
  });
22
- await rabbit.sendToQueue('test-q-2', 'hey-q')
23
- }
24
+ await rabbit.sendToQueue('test-q-2', 'hey-q');
25
+ };
24
26
 
25
- init();
27
+ init();
@@ -0,0 +1,59 @@
1
+ import RabbitMq from './index';
2
+ // import RabbitError from './rabbitError';
3
+
4
+ jest.setTimeout(120000);
5
+
6
+ const rabbit = new RabbitMq();
7
+
8
+ const delay = () => new Promise((resolve) => setTimeout(() => resolve(), 500));
9
+
10
+ describe('RabbitMQ', () => {
11
+ it('check exchange', async () => {
12
+ const callback = (msg: any, ack: any) => {
13
+ expect(msg.content).toEqual('hey');
14
+ ack(msg);
15
+ };
16
+ const mockFn = jest.fn(callback);
17
+ await rabbit.consumeFromExchange('test-q2', 'test-e', mockFn);
18
+ await rabbit.publish('test-e', 'hey');
19
+ await delay();
20
+ expect(mockFn).toBeCalled();
21
+ });
22
+
23
+ it('check queue', async () => {
24
+ const callback = (msg: any, ack: any) => {
25
+ expect(msg.content).toEqual('hey-q');
26
+ ack(msg);
27
+ };
28
+ const mockFn = jest.fn(callback);
29
+ await rabbit.consume('test-q-2', mockFn);
30
+ await rabbit.sendToQueue('test-q-2', 'hey-q');
31
+ await delay();
32
+ expect(mockFn).toBeCalled();
33
+ });
34
+
35
+ it('cant publish to unknown exchange', async () => {
36
+ let err;
37
+ try {
38
+ await rabbit.publish('', 'hey');
39
+ } catch (e) {
40
+ err = e;
41
+ }
42
+ expect(err).toBeDefined();
43
+ });
44
+
45
+ it('cant publish due timeout', async () => {
46
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
47
+ // @ts-ignore
48
+ process.env.RABBITMQ_PUBLISH_TIMEOUT = 1;
49
+ const rabbit2 = new RabbitMq();
50
+
51
+ let err;
52
+ try {
53
+ await rabbit2.publish('test-e', 'hey');
54
+ } catch (e) {
55
+ err = e;
56
+ }
57
+ expect(err).toBeDefined();
58
+ });
59
+ });
package/src/index.ts CHANGED
@@ -1,8 +1,9 @@
1
+ // eslint-disable-next-line max-classes-per-file
2
+ import * as bluebird from 'bluebird';
1
3
  import { ConfirmChannel } from 'amqplib';
2
- import { connect, AmqpConnectionManager, ChannelWrapper } from 'amqp-connection-manager';
4
+ import { AmqpConnectionManager, ChannelWrapper, connect } from 'amqp-connection-manager';
3
5
  import { EventEmitter } from 'events';
4
-
5
- class RabbitError extends Error { }
6
+ import RabbitError from './rabbitError';
6
7
 
7
8
  interface ExchangesCache {
8
9
  [key: string]: any
@@ -16,12 +17,12 @@ class RabbitMq {
16
17
 
17
18
  try {
18
19
  content = JSON.parse(content);
19
- } catch (e) { }
20
+ } catch (e) { } // eslint-disable-line no-empty
20
21
 
21
22
  return {
22
23
  ...msg,
23
24
  content,
24
- }
25
+ };
25
26
  }
26
27
 
27
28
  static validateName(type: string, name: string) {
@@ -30,14 +31,24 @@ class RabbitMq {
30
31
  }
31
32
  }
32
33
 
34
+ PUBLISH_TIMEOUT = Number(process.env.RABBITMQ_PUBLISH_TIMEOUT) || 60000;
35
+
36
+ PUBLISH_ERROR_MSG = `rabbit: publish timeout(${this.PUBLISH_TIMEOUT}ms) has pass, exchange: `;
37
+
38
+ DISCONNECT_MSG = 'rabbit: connection disconnect';
39
+
33
40
  channel: ChannelWrapper | null;
41
+
34
42
  connection: AmqpConnectionManager | null;
43
+
35
44
  em: EventEmitter;
36
- creatingConnection: Boolean;
45
+
46
+ creatingConnection: boolean;
47
+
37
48
  exchanges: ExchangesCache;
38
49
 
39
50
  constructor() {
40
- this.em = new EventEmitter;
51
+ this.em = new EventEmitter();
41
52
  this.channel = null;
42
53
  this.connection = null;
43
54
  this.creatingConnection = false;
@@ -53,6 +64,7 @@ class RabbitMq {
53
64
  public nack = (queue: string) => async (msg: any, retries: number) => {
54
65
  if (this.channel) {
55
66
  if (!msg.content['x-retry-count'] || msg.content['x-retry-count'] <= retries) {
67
+ // eslint-disable-next-line no-param-reassign
56
68
  msg.content['x-retry-count'] = msg.content['x-retry-count'] ? msg.content['x-retry-count'] + 1 : 1;
57
69
  await this.sendToQueue(queue, msg.content);
58
70
  } else {
@@ -65,31 +77,36 @@ class RabbitMq {
65
77
  }
66
78
 
67
79
  async getConnection() {
80
+ // eslint-disable-next-line no-async-promise-executor
68
81
  return new Promise<AmqpConnectionManager>(async (resolve) => {
69
82
  if (this.creatingConnection) {
70
83
  this.em.on(connectionCreatedConst, resolve);
71
84
  return;
72
85
  }
73
86
  if (this.connection !== null) {
87
+ // eslint-disable-next-line consistent-return
74
88
  return this.connection;
75
89
  }
76
90
  this.creatingConnection = true;
77
- let host: string = process.env.RABBITMQ_SERVICE_HOST || '35.240.13.28';
78
- let connection: AmqpConnectionManager = await connect([`amqp://${host}`]);
91
+ const host: string = process.env.RABBITMQ_SERVICE_HOST || '';
92
+ const connection: AmqpConnectionManager = await connect([`amqp://${host}`]);
79
93
  this.connection = connection;
94
+ this.connection.on('disconnect',
95
+ ({ err }) => console.error(`${this.DISCONNECT_MSG}${err && ` - ${err}`}`));
80
96
  this.creatingConnection = false;
81
97
  this.em.emit(connectionCreatedConst, connection);
82
98
  resolve(connection);
83
- })
99
+ });
84
100
  }
85
101
 
86
102
  async assertChannel() {
103
+ // eslint-disable-next-line no-async-promise-executor,consistent-return
87
104
  return new Promise<ChannelWrapper>(async (resolve, reject) => {
88
- if(this.channel) {
105
+ if (this.channel) {
89
106
  return resolve(this.channel);
90
107
  }
91
108
 
92
- let connection: AmqpConnectionManager = await this.getConnection();
109
+ const connection: AmqpConnectionManager = await this.getConnection();
93
110
 
94
111
  try {
95
112
  if (this.channel === null) {
@@ -97,29 +114,32 @@ class RabbitMq {
97
114
  }
98
115
  resolve(this.channel);
99
116
  } catch (e) {
100
- reject(e)
117
+ reject(e);
101
118
  }
102
- })
119
+ });
103
120
  }
104
121
 
122
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
105
123
  async assertExchange(exchangeName: string, options?: any) {
106
124
  const channel: ChannelWrapper = await this.assertChannel();
107
- if(this.exchanges[exchangeName]) {
108
- return this.exchanges[exchangeName]
125
+ if (this.exchanges[exchangeName]) {
126
+ return this.exchanges[exchangeName];
109
127
  }
110
128
  return channel.addSetup(async (c: ConfirmChannel) => {
111
- const exchange = await c.assertExchange(exchangeName, 'fanout')
129
+ const exchange = await c.assertExchange(exchangeName, 'fanout');
112
130
  this.exchanges[exchangeName] = exchange;
113
131
  return exchange;
114
132
  });
115
133
  }
116
134
 
135
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
117
136
  async assertQueue(queue: string, options?: any) {
118
137
  RabbitMq.validateName('queue', queue);
119
138
  const channel: ChannelWrapper = await this.assertChannel();
120
139
  return channel.addSetup((c: ConfirmChannel) => c.assertQueue(queue));
121
140
  }
122
141
 
142
+ // eslint-disable-next-line @typescript-eslint/ban-types
123
143
  async consume(queue: string, callback: (msg: any, ack: Function, nack: Function) => any, options?: any) {
124
144
  RabbitMq.validateName('queue', queue);
125
145
  const { limit } = (options && options.limit) ? options : { limit: 1 };
@@ -133,6 +153,7 @@ class RabbitMq {
133
153
  });
134
154
  }
135
155
 
156
+ // eslint-disable-next-line @typescript-eslint/ban-types
136
157
  async consumeFromExchange(queue: string, exchange: string, callback: (msg: any, ack: Function, nack: Function) => any, options?: any) {
137
158
  RabbitMq.validateName('queue', queue);
138
159
  RabbitMq.validateName('exchange', exchange);
@@ -148,15 +169,18 @@ class RabbitMq {
148
169
  return Promise.all([
149
170
  c.bindQueue(queue, exchange, ''),
150
171
  c.consume(queue, (msg: any) => callback(RabbitMq.parseMsg(msg), this.ack, this.nack(queue))),
151
- ])
152
- })
172
+ ]);
173
+ });
153
174
  }
154
175
 
155
176
  async publish(exchange: string, content: any) {
156
177
  RabbitMq.validateName('exchange', exchange);
157
178
  const channel: ChannelWrapper = await this.assertChannel();
158
179
  await this.assertExchange(exchange);
159
- return channel.publish(exchange, '', Buffer.from(JSON.stringify(content)));
180
+ return new bluebird.Promise(async (resolve) => {
181
+ await channel.publish(exchange, '', Buffer.from(JSON.stringify(content)));
182
+ return resolve();
183
+ }).timeout(this.PUBLISH_TIMEOUT, `${this.PUBLISH_ERROR_MSG}${exchange}`);
160
184
  }
161
185
 
162
186
  async sendToQueue(queue: string, content: any) {
package/src/mock.ts CHANGED
@@ -2,14 +2,22 @@ import 'jest';
2
2
 
3
3
  class RabbitMq {
4
4
  public ack = jest.fn();
5
+
5
6
  public nack = jest.fn();
7
+
6
8
  public assertChannel = jest.fn();
9
+
7
10
  public assertExchange = jest.fn();
11
+
8
12
  public assertQueue = jest.fn();
13
+
9
14
  public consume = jest.fn();
15
+
10
16
  public consumeFromExchange = jest.fn();
17
+
11
18
  public publish = jest.fn();
19
+
12
20
  public sendToQueue = jest.fn();
13
21
  }
14
22
 
15
- export default RabbitMq;
23
+ export default RabbitMq;
@@ -0,0 +1,6 @@
1
+ export default class RabbitError extends Error {
2
+ constructor(message: string) {
3
+ super(message);
4
+ this.name = 'RabbitError';
5
+ }
6
+ }
package/tsconfig.json CHANGED
@@ -1,12 +1,9 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "es2017",
3
+ "target": "es6",
4
4
  "module": "commonjs",
5
- "lib": [
6
- "es2017"
7
- ],
8
5
  "declaration": true,
9
6
  "outDir": "./dist",
10
7
  "strict": true
11
8
  }
12
- }
9
+ }
@@ -1,5 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <state>
3
- <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
- </state>
5
- </component>
@@ -1,158 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="AmdModulesDependencies" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
5
- <inspection_tool class="BadExpressionStatementJS" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
6
- <inspection_tool class="CallerJS" enabled="false" level="WARNING" enabled_by_default="false" />
7
- <inspection_tool class="CommaExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
8
- <inspection_tool class="ConstantConditionalExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
9
- <inspection_tool class="ContinueOrBreakFromFinallyBlockJS" enabled="false" level="WARNING" enabled_by_default="false" />
10
- <inspection_tool class="ES6AwaitOutsideAsyncFunction" enabled="false" level="ERROR" enabled_by_default="false" />
11
- <inspection_tool class="ES6BindWithArrowFunction" enabled="false" level="WARNING" enabled_by_default="false" />
12
- <inspection_tool class="ES6CheckImport" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
13
- <inspection_tool class="ES6ClassMemberInitializationOrder" enabled="false" level="WARNING" enabled_by_default="false" />
14
- <inspection_tool class="ES6ConvertLetToConst" enabled="false" level="INFORMATION" enabled_by_default="false" />
15
- <inspection_tool class="ES6ConvertModuleExportToExport" enabled="false" level="INFORMATION" enabled_by_default="false" />
16
- <inspection_tool class="ES6ConvertRequireIntoImport" enabled="false" level="INFORMATION" enabled_by_default="false" />
17
- <inspection_tool class="ES6ConvertToForOf" enabled="false" level="INFORMATION" enabled_by_default="false" />
18
- <inspection_tool class="ES6ConvertVarToLetConst" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
19
- <inspection_tool class="ES6DestructuringVariablesMerge" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
20
- <inspection_tool class="ES6MissingAwait" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
21
- <inspection_tool class="ES6ModulesDependencies" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
22
- <inspection_tool class="ES6PossiblyAsyncFunction" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
23
- <inspection_tool class="ES6PreferShortImport" enabled="false" level="WARNING" enabled_by_default="false" />
24
- <inspection_tool class="ES6RedundantAwait" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
25
- <inspection_tool class="ES6RedundantNestingInTemplateLiteral" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
26
- <inspection_tool class="ES6ShorthandObjectProperty" enabled="false" level="INFORMATION" enabled_by_default="false" />
27
- <inspection_tool class="ES6UnusedImports" enabled="false" level="WARNING" enabled_by_default="false" />
28
- <inspection_tool class="EmptyStatementBodyJS" enabled="false" level="WARNING" enabled_by_default="false">
29
- <option name="m_reportEmptyBlocks" value="false" />
30
- </inspection_tool>
31
- <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
32
- <inspection_tool class="ExceptionCaughtLocallyJS" enabled="false" level="WARNING" enabled_by_default="false" />
33
- <inspection_tool class="FallThroughInSwitchStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
34
- <inspection_tool class="FlowJSConfig" enabled="false" level="WARNING" enabled_by_default="false" />
35
- <inspection_tool class="FlowJSFlagCommentPlacement" enabled="false" level="WARNING" enabled_by_default="false" />
36
- <inspection_tool class="IncompatibleMaskJS" enabled="false" level="WARNING" enabled_by_default="false" />
37
- <inspection_tool class="InfiniteLoopJS" enabled="false" level="WARNING" enabled_by_default="false" />
38
- <inspection_tool class="InfiniteRecursionJS" enabled="false" level="WARNING" enabled_by_default="false" />
39
- <inspection_tool class="JSAccessibilityCheck" enabled="false" level="WARNING" enabled_by_default="false" />
40
- <inspection_tool class="JSAnnotator" enabled="false" level="ERROR" enabled_by_default="false" />
41
- <inspection_tool class="JSArrowFunctionBracesCanBeRemoved" enabled="false" level="INFORMATION" enabled_by_default="false" />
42
- <inspection_tool class="JSAssignmentUsedAsCondition" enabled="false" level="WARNING" enabled_by_default="false" />
43
- <inspection_tool class="JSBitwiseOperatorUsage" enabled="false" level="WARNING" enabled_by_default="false" />
44
- <inspection_tool class="JSCheckFunctionSignatures" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
45
- <inspection_tool class="JSClosureCompilerSyntax" enabled="false" level="WARNING" enabled_by_default="false" />
46
- <inspection_tool class="JSCommentMatchesSignature" enabled="false" level="WARNING" enabled_by_default="false" />
47
- <inspection_tool class="JSComparisonWithNaN" enabled="false" level="WARNING" enabled_by_default="false" />
48
- <inspection_tool class="JSConsecutiveCommasInArrayLiteral" enabled="false" level="WARNING" enabled_by_default="false" />
49
- <inspection_tool class="JSConstantReassignment" enabled="false" level="ERROR" enabled_by_default="false" />
50
- <inspection_tool class="JSDeprecatedSymbols" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
51
- <inspection_tool class="JSDuplicateCaseLabel" enabled="false" level="WARNING" enabled_by_default="false" />
52
- <inspection_tool class="JSDuplicatedDeclaration" enabled="false" level="WARNING" enabled_by_default="false" />
53
- <inspection_tool class="JSEqualityComparisonWithCoercion" enabled="false" level="WARNING" enabled_by_default="false" />
54
- <inspection_tool class="JSFileReferences" enabled="false" level="WARNING" enabled_by_default="false" />
55
- <inspection_tool class="JSFunctionExpressionToArrowFunction" enabled="false" level="INFORMATION" enabled_by_default="false" />
56
- <inspection_tool class="JSIgnoredPromiseFromCall" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
57
- <inspection_tool class="JSIncompatibleTypesComparison" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
58
- <inspection_tool class="JSJQueryEfficiency" enabled="false" level="WARNING" enabled_by_default="false" />
59
- <inspection_tool class="JSJoinVariableDeclarationAndAssignment" enabled="false" level="INFORMATION" enabled_by_default="false" />
60
- <inspection_tool class="JSLastCommaInArrayLiteral" enabled="false" level="WARNING" enabled_by_default="false" />
61
- <inspection_tool class="JSLastCommaInObjectLiteral" enabled="false" level="WARNING" enabled_by_default="false" />
62
- <inspection_tool class="JSMethodCanBeStatic" enabled="false" level="WARNING" enabled_by_default="false" />
63
- <inspection_tool class="JSMismatchedCollectionQueryUpdate" enabled="false" level="WARNING" enabled_by_default="false">
64
- <option name="queries" value="trace,write,forEach,length,size" />
65
- <option name="updates" value="pop,push,shift,splice,unshift,add,insert,remove,reverse,copyWithin,fill,sort" />
66
- </inspection_tool>
67
- <inspection_tool class="JSMissingSwitchBranches" enabled="false" level="INFORMATION" enabled_by_default="false" />
68
- <inspection_tool class="JSMissingSwitchDefault" enabled="false" level="INFORMATION" enabled_by_default="false" />
69
- <inspection_tool class="JSNonASCIINames" enabled="false" level="WARNING" enabled_by_default="false" />
70
- <inspection_tool class="JSObjectNullOrUndefined" enabled="false" level="WARNING" enabled_by_default="false" />
71
- <inspection_tool class="JSObsoletePrivateAccessSyntax" enabled="false" level="ERROR" enabled_by_default="false" />
72
- <inspection_tool class="JSOctalInteger" enabled="false" level="ERROR" enabled_by_default="false" />
73
- <inspection_tool class="JSPotentiallyInvalidConstructorUsage" enabled="false" level="WARNING" enabled_by_default="false">
74
- <option name="myConsiderUppercaseFunctionsToBeConstructors" value="true" />
75
- </inspection_tool>
76
- <inspection_tool class="JSPotentiallyInvalidTargetOfIndexedPropertyAccess" enabled="false" level="WARNING" enabled_by_default="false" />
77
- <inspection_tool class="JSPotentiallyInvalidUsageOfClassThis" enabled="false" level="WARNING" enabled_by_default="false" />
78
- <inspection_tool class="JSPotentiallyInvalidUsageOfThis" enabled="false" level="WARNING" enabled_by_default="false" />
79
- <inspection_tool class="JSPrimitiveTypeWrapperUsage" enabled="false" level="WARNING" enabled_by_default="false" />
80
- <inspection_tool class="JSRedundantSwitchStatement" enabled="false" level="INFORMATION" enabled_by_default="false" />
81
- <inspection_tool class="JSReferencingArgumentsOutsideOfFunction" enabled="false" level="ERROR" enabled_by_default="false" />
82
- <inspection_tool class="JSReferencingMutableVariableFromClosure" enabled="false" level="WARNING" enabled_by_default="false" />
83
- <inspection_tool class="JSRemoveUnnecessaryParentheses" enabled="false" level="INFORMATION" enabled_by_default="false" />
84
- <inspection_tool class="JSStringConcatenationToES6Template" enabled="false" level="INFORMATION" enabled_by_default="false" />
85
- <inspection_tool class="JSSuspiciousEqPlus" enabled="false" level="WARNING" enabled_by_default="false" />
86
- <inspection_tool class="JSSuspiciousNameCombination" enabled="false" level="WARNING" enabled_by_default="false">
87
- <group names="x,width,left,right" />
88
- <group names="y,height,top,bottom" />
89
- <exclude classes="Math" />
90
- </inspection_tool>
91
- <inspection_tool class="JSSwitchVariableDeclarationIssue" enabled="false" level="WARNING" enabled_by_default="false" />
92
- <inspection_tool class="JSTestFailedLine" enabled="false" level="WARNING" enabled_by_default="false" />
93
- <inspection_tool class="JSTypeOfValues" enabled="false" level="WARNING" enabled_by_default="false" />
94
- <inspection_tool class="JSUndeclaredVariable" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
95
- <inspection_tool class="JSUndefinedPropertyAssignment" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
96
- <inspection_tool class="JSUnfilteredForInLoop" enabled="false" level="WARNING" enabled_by_default="false" />
97
- <inspection_tool class="JSUnnecessarySemicolon" enabled="false" level="WARNING" enabled_by_default="false" />
98
- <inspection_tool class="JSUnreachableSwitchBranches" enabled="false" level="WARNING" enabled_by_default="false" />
99
- <inspection_tool class="JSUnresolvedExtXType" enabled="false" level="WARNING" enabled_by_default="false" />
100
- <inspection_tool class="JSUnresolvedFunction" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
101
- <inspection_tool class="JSUnresolvedLibraryURL" enabled="false" level="WARNING" enabled_by_default="false" />
102
- <inspection_tool class="JSUnresolvedVariable" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
103
- <inspection_tool class="JSUnusedAssignment" enabled="false" level="WARNING" enabled_by_default="false" />
104
- <inspection_tool class="JSUnusedGlobalSymbols" enabled="false" level="WARNING" enabled_by_default="false" />
105
- <inspection_tool class="JSUnusedLocalSymbols" enabled="false" level="WARNING" enabled_by_default="false" />
106
- <inspection_tool class="JSValidateJSDoc" enabled="false" level="WARNING" enabled_by_default="false" />
107
- <inspection_tool class="JSValidateTypes" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
108
- <inspection_tool class="JSXNamespaceValidation" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
109
- <inspection_tool class="KarmaConfigFile" enabled="false" level="WARNING" enabled_by_default="false" />
110
- <inspection_tool class="LoopStatementThatDoesntLoopJS" enabled="false" level="WARNING" enabled_by_default="false" />
111
- <inspection_tool class="NodeCoreCodingAssistance" enabled="false" level="WARNING" enabled_by_default="false" />
112
- <inspection_tool class="NodeModulesDependencies" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
113
- <inspection_tool class="NpmUsedModulesInstalled" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
114
- <inspection_tool class="PackageJsonMismatchedDependency" enabled="false" level="WARNING" enabled_by_default="false" />
115
- <inspection_tool class="PointlessArithmeticExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
116
- <inspection_tool class="PointlessBooleanExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
117
- <inspection_tool class="ReservedWordUsedAsNameJS" enabled="false" level="WARNING" enabled_by_default="false" />
118
- <inspection_tool class="ReturnFromFinallyBlockJS" enabled="false" level="WARNING" enabled_by_default="false" />
119
- <inspection_tool class="ShiftOutOfRangeJS" enabled="false" level="WARNING" enabled_by_default="false" />
120
- <inspection_tool class="SillyAssignmentJS" enabled="false" level="WARNING" enabled_by_default="false" />
121
- <inspection_tool class="SuspiciousTypeOfGuard" enabled="false" level="WARNING" enabled_by_default="false" />
122
- <inspection_tool class="ThisExpressionReferencesGlobalObjectJS" enabled="false" level="WARNING" enabled_by_default="false" />
123
- <inspection_tool class="ThrowFromFinallyBlockJS" enabled="false" level="WARNING" enabled_by_default="false" />
124
- <inspection_tool class="TrivialConditionalJS" enabled="false" level="WARNING" enabled_by_default="false" />
125
- <inspection_tool class="TrivialIfJS" enabled="false" level="WARNING" enabled_by_default="false" />
126
- <inspection_tool class="TypeScriptAbstractClassConstructorCanBeMadeProtected" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
127
- <inspection_tool class="TypeScriptAccessibilityCheck" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
128
- <inspection_tool class="TypeScriptCheckImport" enabled="false" level="ERROR" enabled_by_default="false" />
129
- <inspection_tool class="TypeScriptConfig" enabled="false" level="WARNING" enabled_by_default="false" />
130
- <inspection_tool class="TypeScriptDuplicateUnionOrIntersectionType" enabled="false" level="WARNING" enabled_by_default="false" />
131
- <inspection_tool class="TypeScriptExplicitMemberType" enabled="false" level="INFORMATION" enabled_by_default="false" />
132
- <inspection_tool class="TypeScriptFieldCanBeMadeReadonly" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
133
- <inspection_tool class="TypeScriptLibrary" enabled="false" level="ERROR" enabled_by_default="false" />
134
- <inspection_tool class="TypeScriptMissingAugmentationImport" enabled="false" level="INFORMATION" enabled_by_default="false" />
135
- <inspection_tool class="TypeScriptMissingConfigOption" enabled="false" level="WARNING" enabled_by_default="false" />
136
- <inspection_tool class="TypeScriptRedundantGenericType" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
137
- <inspection_tool class="TypeScriptSmartCast" enabled="false" level="WARNING" enabled_by_default="false" />
138
- <inspection_tool class="TypeScriptSuspiciousConstructorParameterAssignment" enabled="false" level="WARNING" enabled_by_default="false" />
139
- <inspection_tool class="TypeScriptUMDGlobal" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
140
- <inspection_tool class="TypeScriptUnresolvedFunction" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
141
- <inspection_tool class="TypeScriptUnresolvedVariable" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
142
- <inspection_tool class="TypeScriptValidateGenericTypes" enabled="false" level="ERROR" enabled_by_default="false" />
143
- <inspection_tool class="TypeScriptValidateJSTypes" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
144
- <inspection_tool class="TypeScriptValidateTypes" enabled="false" level="ERROR" enabled_by_default="false" />
145
- <inspection_tool class="UnnecessaryContinueJS" enabled="false" level="WARNING" enabled_by_default="false" />
146
- <inspection_tool class="UnnecessaryLabelJS" enabled="false" level="WARNING" enabled_by_default="false" />
147
- <inspection_tool class="UnnecessaryLabelOnBreakStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
148
- <inspection_tool class="UnnecessaryLabelOnContinueStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
149
- <inspection_tool class="UnnecessaryLocalVariableJS" enabled="false" level="WARNING" enabled_by_default="false">
150
- <option name="m_ignoreImmediatelyReturnedVariables" value="false" />
151
- <option name="m_ignoreAnnotatedVariables" value="false" />
152
- </inspection_tool>
153
- <inspection_tool class="UnnecessaryReturnJS" enabled="false" level="WARNING" enabled_by_default="false" />
154
- <inspection_tool class="UnreachableCodeJS" enabled="false" level="WARNING" enabled_by_default="false" />
155
- <inspection_tool class="WebpackConfigHighlighting" enabled="false" level="WARNING" enabled_by_default="false" />
156
- <inspection_tool class="WithStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
157
- </profile>
158
- </component>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/rabbit.iml" filepath="$PROJECT_DIR$/.idea/rabbit.iml" />
6
- </modules>
7
- </component>
8
- </project>
package/.idea/rabbit.iml DELETED
@@ -1,12 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="WEB_MODULE" version="4">
3
- <component name="NewModuleRootManager">
4
- <content url="file://$MODULE_DIR$">
5
- <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6
- <excludeFolder url="file://$MODULE_DIR$/temp" />
7
- <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
- </content>
9
- <orderEntry type="inheritedJdk" />
10
- <orderEntry type="sourceFolder" forTests="false" />
11
- </component>
12
- </module>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>
@@ -1,92 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="AutoImportSettings">
4
- <option name="autoReloadType" value="SELECTIVE" />
5
- </component>
6
- <component name="ChangeListManager">
7
- <list default="true" id="1723b515-3530-42bb-82ff-6779499ab47b" name="Default Changelist" comment="" />
8
- <option name="SHOW_DIALOG" value="false" />
9
- <option name="HIGHLIGHT_CONFLICTS" value="true" />
10
- <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
11
- <option name="LAST_RESOLUTION" value="IGNORE" />
12
- </component>
13
- <component name="Git.Settings">
14
- <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
15
- </component>
16
- <component name="ProjectId" id="1kkbq4cPpgJtXBPfswsGj3HyZyE" />
17
- <component name="ProjectViewState">
18
- <option name="compactDirectories" value="true" />
19
- <option name="hideEmptyMiddlePackages" value="true" />
20
- <option name="showLibraryContents" value="true" />
21
- <option name="showMembers" value="true" />
22
- </component>
23
- <component name="PropertiesComponent">
24
- <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
25
- <property name="WebServerToolWindowFactoryState" value="false" />
26
- <property name="editorconfig.notification" value="null" />
27
- <property name="last_opened_file_path" value="$PROJECT_DIR$" />
28
- <property name="node.js.detected.package.eslint" value="true" />
29
- <property name="node.js.path.for.package.eslint" value="project" />
30
- <property name="node.js.selected.package.eslint" value="(autodetect)" />
31
- <property name="nodejs_package_manager_path" value="npm" />
32
- <property name="settings.editor.selected.configurable" value="preference.i18nPlugin" />
33
- <property name="ts.external.directory.path" value="$APPLICATION_HOME_DIR$/plugins/JavaScriptLanguage/jsLanguageServicesImpl/external" />
34
- <property name="vue.rearranger.settings.migration" value="true" />
35
- </component>
36
- <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
37
- <component name="TaskManager">
38
- <task active="true" id="Default" summary="Default task">
39
- <changelist id="1723b515-3530-42bb-82ff-6779499ab47b" name="Default Changelist" comment="" />
40
- <created>1606247725673</created>
41
- <option name="number" value="Default" />
42
- <option name="presentableId" value="Default" />
43
- <updated>1606247725673</updated>
44
- <workItem from="1606247727265" duration="11736000" />
45
- </task>
46
- <task id="LOCAL-00001" summary="validate name before usage">
47
- <created>1606375684964</created>
48
- <option name="number" value="00001" />
49
- <option name="presentableId" value="LOCAL-00001" />
50
- <option name="project" value="LOCAL" />
51
- <updated>1606375684964</updated>
52
- </task>
53
- <option name="localTasksCounter" value="2" />
54
- <servers />
55
- </component>
56
- <component name="TypeScriptGeneratedFilesManager">
57
- <option name="version" value="3" />
58
- </component>
59
- <component name="Vcs.Log.Tabs.Properties">
60
- <option name="TAB_STATES">
61
- <map>
62
- <entry key="MAIN">
63
- <value>
64
- <State />
65
- </value>
66
- </entry>
67
- </map>
68
- </option>
69
- </component>
70
- <component name="VcsManagerConfiguration">
71
- <MESSAGE value="validate name before usage" />
72
- <option name="LAST_COMMIT_MESSAGE" value="validate name before usage" />
73
- </component>
74
- <component name="WindowStateProjectService">
75
- <state x="0" y="25" width="1792" height="1095" key="CommitChangelistDialog2" timestamp="1606375684235">
76
- <screen x="0" y="25" width="1792" height="1095" />
77
- </state>
78
- <state x="0" y="25" width="1792" height="1095" key="CommitChangelistDialog2/0.25.1792.1095/1792.25.1920.1055@0.25.1792.1095" timestamp="1606375684235" />
79
- <state x="100" y="125" width="1592" height="895" key="DiffContextDialog" timestamp="1606321283909">
80
- <screen x="0" y="25" width="1792" height="1095" />
81
- </state>
82
- <state x="100" y="125" width="1592" height="895" key="DiffContextDialog/0.25.1792.1095/1792.25.1920.1055@0.25.1792.1095" timestamp="1606321283909" />
83
- <state x="496" y="291" key="Vcs.Push.Dialog.v2" timestamp="1606375687293">
84
- <screen x="0" y="25" width="1792" height="1095" />
85
- </state>
86
- <state x="496" y="291" key="Vcs.Push.Dialog.v2/0.25.1792.1095/1792.25.1920.1055@0.25.1792.1095" timestamp="1606375687293" />
87
- <state x="561" y="269" width="670" height="676" key="search.everywhere.popup" timestamp="1606323061773">
88
- <screen x="0" y="25" width="1792" height="1095" />
89
- </state>
90
- <state x="561" y="269" width="670" height="676" key="search.everywhere.popup/0.25.1792.1095/1792.25.1920.1055@0.25.1792.1095" timestamp="1606323061773" />
91
- </component>
92
- </project>