@ubs-platform/nest-microservice-setup-util 3.2.0 → 4.2.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -4,30 +4,18 @@ exports.getMicroserviceConnection = void 0;
|
|
4
4
|
const microservices_1 = require("@nestjs/microservices");
|
5
5
|
const crypto_1 = require("crypto");
|
6
6
|
const getMicroserviceConnection = (groupName) => {
|
7
|
-
const type = process.env[
|
7
|
+
const type = process.env["NX_MICROSERVICE_TYPE"];
|
8
8
|
let microservice = null;
|
9
|
-
if (type ==
|
9
|
+
if (type == "KAFKA") {
|
10
10
|
microservice = {
|
11
11
|
transport: microservices_1.Transport.KAFKA,
|
12
12
|
options: {
|
13
13
|
client: {
|
14
|
-
clientId:
|
15
|
-
brokers: [`${process.env[
|
14
|
+
clientId: "users",
|
15
|
+
brokers: [`${process.env["NX_KAFKA_URL"]}`],
|
16
16
|
},
|
17
17
|
consumer: {
|
18
|
-
groupId:
|
19
|
-
},
|
20
|
-
},
|
21
|
-
};
|
22
|
-
}
|
23
|
-
else if (type == 'RMQ') {
|
24
|
-
microservice = {
|
25
|
-
transport: microservices_1.Transport.RMQ,
|
26
|
-
options: {
|
27
|
-
urls: [process.env['NX_RMQ_URL']],
|
28
|
-
queue: 'cats_queue',
|
29
|
-
queueOptions: {
|
30
|
-
durable: false,
|
18
|
+
groupId: "tk" + (0, crypto_1.randomUUID)(),
|
31
19
|
},
|
32
20
|
},
|
33
21
|
};
|
@@ -36,20 +24,13 @@ const getMicroserviceConnection = (groupName) => {
|
|
36
24
|
microservice = {
|
37
25
|
transport: microservices_1.Transport.TCP,
|
38
26
|
options: {
|
39
|
-
host: process.env[
|
40
|
-
port: process.env[
|
27
|
+
host: process.env["NX_TCP_HOST"],
|
28
|
+
port: process.env["NX_TCP_PORT"],
|
41
29
|
},
|
42
30
|
};
|
43
31
|
}
|
44
|
-
// return {
|
45
|
-
// transport: Transport.TCP,
|
46
|
-
// options: {
|
47
|
-
// host: 'localhost',
|
48
|
-
// port: 7177,
|
49
|
-
// },
|
50
|
-
// };
|
51
32
|
if (microservice == null) {
|
52
|
-
throw
|
33
|
+
throw "Microservice type not recognized";
|
53
34
|
}
|
54
35
|
return microservice;
|
55
36
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nest-microservice-setup-util.js","sourceRoot":"","sources":["../../src/lib/nest-microservice-setup-util.ts"],"names":[],"mappings":";;;AAAA,yDAAkD;AAClD,mCAAoC;AAC7B,MAAM,yBAAyB,GAAG,CAAC,SAAS,EAAE,EAAE;IACrD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,
|
1
|
+
{"version":3,"file":"nest-microservice-setup-util.js","sourceRoot":"","sources":["../../src/lib/nest-microservice-setup-util.ts"],"names":[],"mappings":";;;AAAA,yDAAkD;AAClD,mCAAoC;AAC7B,MAAM,yBAAyB,GAAG,CAAC,SAAS,EAAE,EAAE;IACrD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAoB,CAAC;IAEpE,IAAI,YAAY,GAAkB,IAAI,CAAC;IACvC,IAAI,IAAI,IAAI,OAAO,EAAE,CAAC;QACpB,YAAY,GAAG;YACb,SAAS,EAAE,yBAAS,CAAC,KAAK;YAC1B,OAAO,EAAE;gBACP,MAAM,EAAE;oBACN,QAAQ,EAAE,OAAO;oBACjB,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;iBAC5C;gBACD,QAAQ,EAAE;oBACR,OAAO,EAAE,IAAI,GAAG,IAAA,mBAAU,GAAE;iBAC7B;aACF;SACF,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,YAAY,GAAG;YACb,SAAS,EAAE,yBAAS,CAAC,GAAG;YACxB,OAAO,EAAE;gBACP,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;gBAChC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;aACjC;SACF,CAAC;IACJ,CAAC;IACD,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC;QACzB,MAAM,kCAAkC,CAAC;IAC3C,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AA9BW,QAAA,yBAAyB,6BA8BpC;AACF,+CAA+C;AAE/C,6EAA6E;AAC7E,+CAA+C"}
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{ "name": "@ubs-platform/nest-microservice-setup-util", "version": "
|
1
|
+
{ "name": "@ubs-platform/nest-microservice-setup-util", "version": "4.2.1", "private": false, "main": "dist/index.js", "author": "Unlimited Bundle Systems", "homepage": "https://github.com/ubs-platform/nest-microservice-setup-util", "repository": { "type": "git", "url": "https://github.com/ubs-platform/nest-microservice-setup-util" }, "license": "MIT", "scripts": { "build": "tsc", "build-publish": "npm run build && npm publish" }, "peerDependencies": { "@nestjs/microservices": "^11.0.7" }, "dependencies": { "tslib": "^2.8.1", "crypto-promise": "^2.1.0" }, "devDependencies": { "typescript": "~5.3.2", "@types/node": "~18.16.9" }, "publishConfig": { "access": "public" } }
|
@@ -1,30 +1,19 @@
|
|
1
|
-
import { Transport } from
|
2
|
-
import { randomUUID } from
|
1
|
+
import { Transport } from "@nestjs/microservices";
|
2
|
+
import { randomUUID } from "crypto";
|
3
3
|
export const getMicroserviceConnection = (groupName) => {
|
4
|
-
const type = process.env[
|
4
|
+
const type = process.env["NX_MICROSERVICE_TYPE"] as "KAFKA" | "TCP";
|
5
5
|
|
6
6
|
let microservice: Object | null = null;
|
7
|
-
if (type ==
|
7
|
+
if (type == "KAFKA") {
|
8
8
|
microservice = {
|
9
9
|
transport: Transport.KAFKA,
|
10
10
|
options: {
|
11
11
|
client: {
|
12
|
-
clientId:
|
13
|
-
brokers: [`${process.env[
|
12
|
+
clientId: "users",
|
13
|
+
brokers: [`${process.env["NX_KAFKA_URL"]}`],
|
14
14
|
},
|
15
15
|
consumer: {
|
16
|
-
groupId:
|
17
|
-
},
|
18
|
-
},
|
19
|
-
};
|
20
|
-
} else if (type == 'RMQ') {
|
21
|
-
microservice = {
|
22
|
-
transport: Transport.RMQ,
|
23
|
-
options: {
|
24
|
-
urls: [process.env['NX_RMQ_URL']],
|
25
|
-
queue: 'cats_queue',
|
26
|
-
queueOptions: {
|
27
|
-
durable: false,
|
16
|
+
groupId: "tk" + randomUUID(),
|
28
17
|
},
|
29
18
|
},
|
30
19
|
};
|
@@ -32,21 +21,13 @@ export const getMicroserviceConnection = (groupName) => {
|
|
32
21
|
microservice = {
|
33
22
|
transport: Transport.TCP,
|
34
23
|
options: {
|
35
|
-
host: process.env[
|
36
|
-
port: process.env[
|
24
|
+
host: process.env["NX_TCP_HOST"],
|
25
|
+
port: process.env["NX_TCP_PORT"],
|
37
26
|
},
|
38
27
|
};
|
39
28
|
}
|
40
|
-
|
41
|
-
// return {
|
42
|
-
// transport: Transport.TCP,
|
43
|
-
// options: {
|
44
|
-
// host: 'localhost',
|
45
|
-
// port: 7177,
|
46
|
-
// },
|
47
|
-
// };
|
48
29
|
if (microservice == null) {
|
49
|
-
throw
|
30
|
+
throw "Microservice type not recognized";
|
50
31
|
}
|
51
32
|
return microservice;
|
52
33
|
};
|