@ecom-micro/common 2.0.24 → 2.0.27
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/build/index.d.ts +1 -8
- package/build/index.js +9 -8
- package/build/queues/connection.d.ts +10 -0
- package/build/queues/connection.js +50 -0
- package/package.json +32 -31
package/build/index.d.ts
CHANGED
|
@@ -9,11 +9,4 @@ export * from './middleware/restrictTo';
|
|
|
9
9
|
export * from './middleware/requestValidation';
|
|
10
10
|
export * from './middleware/requireAuth';
|
|
11
11
|
export * from './middleware/currentUser';
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './events/basePublisher';
|
|
14
|
-
export * from './events/productCreatedEvent';
|
|
15
|
-
export * from './events/productUpdatedEvent';
|
|
16
|
-
export * from './events/productDeletedEvent';
|
|
17
|
-
export * from './events/sellerCreatedEvent';
|
|
18
|
-
export * from './events/sellerUpdatedEvent';
|
|
19
|
-
export * from './types/subjects';
|
|
12
|
+
export * from './queues/connection';
|
package/build/index.js
CHANGED
|
@@ -25,11 +25,12 @@ __exportStar(require("./middleware/restrictTo"), exports);
|
|
|
25
25
|
__exportStar(require("./middleware/requestValidation"), exports);
|
|
26
26
|
__exportStar(require("./middleware/requireAuth"), exports);
|
|
27
27
|
__exportStar(require("./middleware/currentUser"), exports);
|
|
28
|
-
__exportStar(require("./
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
__exportStar(require("./queues/connection"), exports);
|
|
29
|
+
// export * from './events/baseListener';
|
|
30
|
+
// export * from './events/basePublisher';
|
|
31
|
+
// export * from './events/productCreatedEvent';
|
|
32
|
+
// export * from './events/productUpdatedEvent';
|
|
33
|
+
// export * from './events/productDeletedEvent';
|
|
34
|
+
// export * from './events/sellerCreatedEvent';
|
|
35
|
+
// export * from './events/sellerUpdatedEvent';
|
|
36
|
+
// export * from './types/subjects';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Channel } from "amqplib";
|
|
2
|
+
declare class QueueConnection {
|
|
3
|
+
private readonly endPoint;
|
|
4
|
+
private connection;
|
|
5
|
+
private channel;
|
|
6
|
+
constructor(endPoint: string);
|
|
7
|
+
createConnection(): Promise<Channel | undefined>;
|
|
8
|
+
private closeConnection;
|
|
9
|
+
}
|
|
10
|
+
export { QueueConnection };
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.QueueConnection = void 0;
|
|
16
|
+
const amqplib_1 = __importDefault(require("amqplib"));
|
|
17
|
+
class QueueConnection {
|
|
18
|
+
constructor(endPoint) {
|
|
19
|
+
this.endPoint = endPoint;
|
|
20
|
+
this.connection = undefined;
|
|
21
|
+
this.channel = undefined;
|
|
22
|
+
}
|
|
23
|
+
createConnection() {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
try {
|
|
26
|
+
this.connection = yield amqplib_1.default.connect(this.endPoint);
|
|
27
|
+
this.channel = yield this.connection.createChannel();
|
|
28
|
+
this.closeConnection();
|
|
29
|
+
console.log('Notification server connected to queue successfully...');
|
|
30
|
+
return this.channel;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.log('error', 'NotificationService error createConnection() method:', error);
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
closeConnection() {
|
|
39
|
+
process.once('SIGINT', () => __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
if (this.connection) {
|
|
42
|
+
yield ((_a = this.connection) === null || _a === void 0 ? void 0 : _a.close());
|
|
43
|
+
}
|
|
44
|
+
if (this.channel) {
|
|
45
|
+
yield ((_b = this.channel) === null || _b === void 0 ? void 0 : _b.close());
|
|
46
|
+
}
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.QueueConnection = QueueConnection;
|
package/package.json
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@ecom-micro/common",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "./build/index.js",
|
|
6
|
-
"types": "./build/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"build/**/*"
|
|
9
|
-
],
|
|
10
|
-
"scripts": {
|
|
11
|
-
"clean": "npx rimraf ./build",
|
|
12
|
-
"build": "npm run clean && tsc",
|
|
13
|
-
"pub": "git add . && git commit -m \"Updates\" && npm version patch && npm run build && npm publish"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [],
|
|
16
|
-
"author": "",
|
|
17
|
-
"license": "ISC",
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"@types/amqplib": "^0.10.0",
|
|
20
|
-
"@types/cookie-session": "^2.0.44",
|
|
21
|
-
"@types/express": "^4.17.14",
|
|
22
|
-
"@types/express-validator": "^3.0.0",
|
|
23
|
-
"@types/jsonwebtoken": "^8.5.9",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"express
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@ecom-micro/common",
|
|
3
|
+
"version": "2.0.27",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./build/index.js",
|
|
6
|
+
"types": "./build/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"build/**/*"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"clean": "npx rimraf ./build",
|
|
12
|
+
"build": "npm run clean && tsc",
|
|
13
|
+
"pub": "git add . && git commit -m \"Updates\" && npm version patch && npm run build && npm publish"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [],
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@types/amqplib": "^0.10.0",
|
|
20
|
+
"@types/cookie-session": "^2.0.44",
|
|
21
|
+
"@types/express": "^4.17.14",
|
|
22
|
+
"@types/express-validator": "^3.0.0",
|
|
23
|
+
"@types/jsonwebtoken": "^8.5.9",
|
|
24
|
+
"amqplib": "^0.10.3",
|
|
25
|
+
"cookie-session": "^2.0.0",
|
|
26
|
+
"express": "^4.18.2",
|
|
27
|
+
"express-validator": "^6.14.2",
|
|
28
|
+
"jsonwebtoken": "^8.5.1",
|
|
29
|
+
"node-nats-streaming": "^0.2.6",
|
|
30
|
+
"typescript": "^4.8.4"
|
|
31
|
+
}
|
|
32
|
+
}
|