@ubs-platform/nest-microservice-setup-util 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -0
- package/README.md +3 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib/nest-microservice-setup-util.d.ts +1 -0
- package/dist/src/lib/nest-microservice-setup-util.js +60 -0
- package/dist/src/lib/nest-microservice-setup-util.js.map +1 -0
- package/package.json +9 -2
- package/tsconfig.json +23 -12
- package/project.json +0 -24
- package/tsconfig.lib.json +0 -11
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 UBS Platform
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './lib/nest-microservice-setup-util';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,6EAAmD"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const getMicroserviceConnection: (groupName: any) => Object;
|
@@ -0,0 +1,60 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getMicroserviceConnection = void 0;
|
4
|
+
const microservices_1 = require("@nestjs/microservices");
|
5
|
+
const crypto_1 = require("crypto");
|
6
|
+
const getMicroserviceConnection = (groupName) => {
|
7
|
+
const type = process.env['NX_MICROSERVICE_TYPE'];
|
8
|
+
let microservice = null;
|
9
|
+
if (type == 'KAFKA') {
|
10
|
+
microservice = {
|
11
|
+
transport: microservices_1.Transport.KAFKA,
|
12
|
+
options: {
|
13
|
+
client: {
|
14
|
+
clientId: 'users',
|
15
|
+
brokers: [`${process.env['NX_KAFKA_URL']}`],
|
16
|
+
},
|
17
|
+
consumer: {
|
18
|
+
groupId: 'tk' + (0, crypto_1.randomUUID)(),
|
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,
|
31
|
+
},
|
32
|
+
},
|
33
|
+
};
|
34
|
+
}
|
35
|
+
else {
|
36
|
+
microservice = {
|
37
|
+
transport: microservices_1.Transport.TCP,
|
38
|
+
options: {
|
39
|
+
host: process.env['NX_TCP_HOST'],
|
40
|
+
port: process.env['NX_TCP_PORT'],
|
41
|
+
},
|
42
|
+
};
|
43
|
+
}
|
44
|
+
// return {
|
45
|
+
// transport: Transport.TCP,
|
46
|
+
// options: {
|
47
|
+
// host: 'localhost',
|
48
|
+
// port: 7177,
|
49
|
+
// },
|
50
|
+
// };
|
51
|
+
if (microservice == null) {
|
52
|
+
throw 'Microservice type not recognized';
|
53
|
+
}
|
54
|
+
return microservice;
|
55
|
+
};
|
56
|
+
exports.getMicroserviceConnection = getMicroserviceConnection;
|
57
|
+
// export const UserMicroserviceCommunication =
|
58
|
+
// // More 2 3 kafka clients are needed, comes replication invalid shit error
|
59
|
+
// export const UserMicroserviceCommunication =
|
60
|
+
//# sourceMappingURL=nest-microservice-setup-util.js.map
|
@@ -0,0 +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,CAA4B,CAAC;IAE5E,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,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,YAAY,GAAG;YACb,SAAS,EAAE,yBAAS,CAAC,GAAG;YACxB,OAAO,EAAE;gBACP,IAAI,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;gBACjC,KAAK,EAAE,YAAY;gBACnB,YAAY,EAAE;oBACZ,OAAO,EAAE,KAAK;iBACf;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;IAED,WAAW;IACX,8BAA8B;IAC9B,eAAe;IACf,yBAAyB;IACzB,kBAAkB;IAClB,OAAO;IACP,KAAK;IACL,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC;QACzB,MAAM,kCAAkC,CAAC;IAC3C,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAjDW,QAAA,yBAAyB,6BAiDpC;AACF,+CAA+C;AAE/C,6EAA6E;AAC7E,+CAA+C"}
|
package/package.json
CHANGED
@@ -1,10 +1,17 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ubs-platform/nest-microservice-setup-util",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.2",
|
4
4
|
"private": false,
|
5
|
+
"main": "dist/index.js",
|
6
|
+
"author": "Unlimited Bundle Systems",
|
7
|
+
"homepage": "https://github.com/ubs-platform/nest-microservice-setup-util",
|
8
|
+
"repository": {
|
9
|
+
"type": "git",
|
10
|
+
"url": "https://github.com/ubs-platform/nest-microservice-setup-util"
|
11
|
+
},
|
5
12
|
"scripts": {
|
6
13
|
"build": "tsc",
|
7
|
-
"publish": "npm run build &&
|
14
|
+
"publish": "npm run build && npm publish"
|
8
15
|
},
|
9
16
|
"peerDependencies": {
|
10
17
|
"@nestjs/microservices": "^10.3.3"
|
package/tsconfig.json
CHANGED
@@ -1,16 +1,27 @@
|
|
1
1
|
{
|
2
|
-
"
|
2
|
+
"compileOnSave": false,
|
3
3
|
"compilerOptions": {
|
4
|
-
"
|
4
|
+
"rootDir": ".",
|
5
|
+
"sourceMap": true,
|
6
|
+
"moduleResolution": "node",
|
7
|
+
"emitDecoratorMetadata": true,
|
8
|
+
"experimentalDecorators": true,
|
9
|
+
"importHelpers": true,
|
10
|
+
"target": "es2015",
|
11
|
+
"module": "commonjs",
|
12
|
+
"outDir": "./dist",
|
13
|
+
"lib": ["es2020", "dom"],
|
14
|
+
"skipLibCheck": true,
|
15
|
+
"skipDefaultLibCheck": true,
|
16
|
+
"declaration": true,
|
17
|
+
"types": ["node"]
|
5
18
|
},
|
6
|
-
"
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}
|
15
|
-
]
|
19
|
+
"exclude": [
|
20
|
+
"node_modules",
|
21
|
+
"tmp",
|
22
|
+
"jest.config.ts",
|
23
|
+
"src/**/*.spec.ts",
|
24
|
+
"src/**/*.test.ts"
|
25
|
+
],
|
26
|
+
"include": ["src/**/*.ts"]
|
16
27
|
}
|
package/project.json
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "nest-microservice-setup-util",
|
3
|
-
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
4
|
-
"sourceRoot": "libs/nest-microservice-setup-util/src",
|
5
|
-
"projectType": "library",
|
6
|
-
"targets": {
|
7
|
-
"build": {
|
8
|
-
"executor": "@nx/js:tsc",
|
9
|
-
"outputs": ["{options.outputPath}"],
|
10
|
-
"options": {
|
11
|
-
"outputPath": "dist/libs/nest-microservice-setup-util",
|
12
|
-
"tsConfig": "libs/nest-microservice-setup-util/tsconfig.lib.json",
|
13
|
-
"packageJson": "libs/nest-microservice-setup-util/package.json",
|
14
|
-
"main": "libs/nest-microservice-setup-util/src/index.ts",
|
15
|
-
"assets": ["libs/nest-microservice-setup-util/*.md"]
|
16
|
-
}
|
17
|
-
},
|
18
|
-
"publish": {
|
19
|
-
"command": "node tools/scripts/publish.mjs nest-microservice-setup-util {args.ver} {args.tag}",
|
20
|
-
"dependsOn": ["build"]
|
21
|
-
}
|
22
|
-
},
|
23
|
-
"tags": []
|
24
|
-
}
|
package/tsconfig.lib.json
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"extends": "./tsconfig.json",
|
3
|
-
"compilerOptions": {
|
4
|
-
"module": "commonjs",
|
5
|
-
"outDir": "../../dist/out-tsc",
|
6
|
-
"declaration": true,
|
7
|
-
"types": ["node"]
|
8
|
-
},
|
9
|
-
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
|
10
|
-
"include": ["src/**/*.ts"]
|
11
|
-
}
|