@experts_hub/shared 1.0.23 → 1.0.25

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/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # @los_generic/shared
2
2
 
3
- A public shared library containing DTOs, interfaces, utilities, and other common code for LOS applications.
3
+ A public shared library containing DTOs, interfaces, utilities, and other common code for experts hub applications.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @los_generic/shared
8
+ npm install @experts_hub/shared
9
9
  ```
10
10
 
11
11
  ## Features
@@ -22,50 +22,6 @@ npm install @los_generic/shared
22
22
  - Pagination utilities
23
23
  - More utilities can be added as needed
24
24
 
25
- ## Usage Examples
26
-
27
- ### Using DTOs
28
-
29
- ```typescript
30
- import { CreateCountryDto, UpdateCountryDto } from '@los_generic/shared';
31
-
32
- @Post()
33
- async createCountry(@Body() createCountryDto: CreateCountryDto) {
34
- // DTO will automatically validate the input
35
- return this.countryService.create(createCountryDto);
36
- }
37
-
38
- @Put(':id')
39
- async updateCountry(
40
- @Param('id') id: string,
41
- @Body() updateCountryDto: UpdateCountryDto
42
- ) {
43
- return this.countryService.update(id, updateCountryDto);
44
- }
45
- ```
46
-
47
- ### Using Pagination
48
-
49
- ```typescript
50
- import {
51
- PaginationParams,
52
- createPaginatedResponse,
53
- getPaginationParams
54
- } from '@los_generic/shared';
55
-
56
- @Get()
57
- async findAll(@Query() query: PaginationParams) {
58
- const params = getPaginationParams(query);
59
- const [items, total] = await this.repository.findAndCount({
60
- skip: (params.page - 1) * params.limit,
61
- take: params.limit,
62
- order: { [params.sortBy]: params.sortOrder }
63
- });
64
-
65
- return createPaginatedResponse(items, total, params);
66
- }
67
- ```
68
-
69
25
  ## Development
70
26
 
71
27
  1. Install dependencies:
@@ -85,7 +41,7 @@ npm run watch
85
41
 
86
42
  ## Publishing
87
43
 
88
- This package is published as a public package under the @los_generic organization.
44
+ This package is published as a public package under the @experts_hub organization.
89
45
 
90
46
  ```bash
91
47
  # For bug fixes (0.0.x)
@@ -0,0 +1,2 @@
1
+ export * from './tcp/user.tcp.adapter';
2
+ export * from './rmq/user.rmq.adapter';
@@ -0,0 +1,2 @@
1
+ import { MicroserviceOptions } from "@nestjs/microservices";
2
+ export declare const UserRMQAdapter: (mode?: string) => MicroserviceOptions;
@@ -0,0 +1,2 @@
1
+ import { MicroserviceOptions } from '@nestjs/microservices';
2
+ export declare const UserTCPAdapter: () => MicroserviceOptions;
package/dist/index.d.mts CHANGED
@@ -1,3 +1,5 @@
1
+ import { MicroserviceOptions } from '@nestjs/microservices';
2
+
1
3
  declare const AUTHENTICATION_PATTERN: {
2
4
  handleValidateToken: string;
3
5
  handleLogin: string;
@@ -8,4 +10,8 @@ declare const AUTHENTICATION_PATTERN: {
8
10
  revokeSession: string;
9
11
  };
10
12
 
11
- export { AUTHENTICATION_PATTERN };
13
+ declare const UserTCPAdapter: () => MicroserviceOptions;
14
+
15
+ declare const UserRMQAdapter: (mode?: string) => MicroserviceOptions;
16
+
17
+ export { AUTHENTICATION_PATTERN, UserRMQAdapter, UserTCPAdapter };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { MicroserviceOptions } from '@nestjs/microservices';
2
+
1
3
  declare const AUTHENTICATION_PATTERN: {
2
4
  handleValidateToken: string;
3
5
  handleLogin: string;
@@ -8,4 +10,8 @@ declare const AUTHENTICATION_PATTERN: {
8
10
  revokeSession: string;
9
11
  };
10
12
 
11
- export { AUTHENTICATION_PATTERN };
13
+ declare const UserTCPAdapter: () => MicroserviceOptions;
14
+
15
+ declare const UserRMQAdapter: (mode?: string) => MicroserviceOptions;
16
+
17
+ export { AUTHENTICATION_PATTERN, UserRMQAdapter, UserTCPAdapter };
package/dist/index.js CHANGED
@@ -19,7 +19,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/index.ts
20
20
  var index_exports = {};
21
21
  __export(index_exports, {
22
- AUTHENTICATION_PATTERN: () => AUTHENTICATION_PATTERN
22
+ AUTHENTICATION_PATTERN: () => AUTHENTICATION_PATTERN,
23
+ UserRMQAdapter: () => UserRMQAdapter,
24
+ UserTCPAdapter: () => UserTCPAdapter
23
25
  });
24
26
  module.exports = __toCommonJS(index_exports);
25
27
 
@@ -33,7 +35,81 @@ var AUTHENTICATION_PATTERN = {
33
35
  fetchSessions: "fetch.sessions",
34
36
  revokeSession: "revoke.session"
35
37
  };
38
+
39
+ // src/adapters/tcp/user.tcp.adapter.ts
40
+ var import_dotenv = require("dotenv");
41
+ var import_microservices = require("@nestjs/microservices");
42
+ (0, import_dotenv.config)();
43
+ var UserTCPAdapter = () => {
44
+ return {
45
+ name: "USER_MICROSERVICE",
46
+ transport: import_microservices.Transport.TCP,
47
+ options: {
48
+ host: process.env.USER_MICROSERVICE_TCP_HOST || "localhost",
49
+ port: parseInt(process.env.USER_MICROSERVICE_TCP_PORT || "4001", 10)
50
+ }
51
+ };
52
+ };
53
+
54
+ // src/adapters/rmq/user.rmq.adapter.ts
55
+ var import_dotenv2 = require("dotenv");
56
+ var import_microservices2 = require("@nestjs/microservices");
57
+ (0, import_dotenv2.config)();
58
+ var UserRMQAdapter = (mode = "microservice") => {
59
+ const urls = process.env.USER_MICROSERVICE_RMQ_URL?.split(",") || [
60
+ "amqp://localhost:5672"
61
+ ];
62
+ const queue = process.env.USER_MICROSERVICE_RMQ_QUEUE || "user_queue";
63
+ const prefetchCount = parseInt(
64
+ process.env.USER_MICROSERVICE_RMQ_PREFETCH_COUNT || "10"
65
+ );
66
+ const heartbeat = parseInt(
67
+ process.env.USER_MICROSERVICE_RMQ_HEARTBEAT || "60"
68
+ );
69
+ const deadLetterExchange = process.env.USER_MICROSERVICE_RMQ_DLX || "user_dlx";
70
+ const deadLetterQueue = process.env.USER_MICROSERVICE_RMQ_DLQ || "user_dlq";
71
+ const messageTtl = parseInt(
72
+ process.env.USER_MICROSERVICE_RMQ_MESSAGE_TTL || "30000"
73
+ );
74
+ const config3 = {
75
+ name: "USER_MICROSERVICE",
76
+ transport: import_microservices2.Transport.RMQ,
77
+ options: {
78
+ urls,
79
+ queue,
80
+ prefetchCount,
81
+ heartbeat,
82
+ queueOptions: {
83
+ durable: true,
84
+ arguments: {
85
+ "x-dead-letter-exchange": deadLetterExchange,
86
+ "x-dead-letter-routing-key": deadLetterQueue,
87
+ "x-message-ttl": messageTtl
88
+ }
89
+ },
90
+ connectionOptions: {
91
+ heartbeat,
92
+ retry: true,
93
+ retryAttempts: 5,
94
+ retryDelay: 3e3,
95
+ timeout: 1e4,
96
+ poolSize: parseInt(process.env.MICROSERVICE_RMQ_POOL_SIZE || "5"),
97
+ ...process.env.USER_MICROSERVICE_RMQ_USE_SSL === "true" && {
98
+ ssl: {
99
+ rejectUnauthorized: false
100
+ }
101
+ }
102
+ }
103
+ }
104
+ };
105
+ if (mode === "microservice") {
106
+ config3["options"]["noAck"] = false;
107
+ }
108
+ return config3;
109
+ };
36
110
  // Annotate the CommonJS export names for ESM import in node:
37
111
  0 && (module.exports = {
38
- AUTHENTICATION_PATTERN
112
+ AUTHENTICATION_PATTERN,
113
+ UserRMQAdapter,
114
+ UserTCPAdapter
39
115
  });
package/dist/index.mjs CHANGED
@@ -8,6 +8,80 @@ var AUTHENTICATION_PATTERN = {
8
8
  fetchSessions: "fetch.sessions",
9
9
  revokeSession: "revoke.session"
10
10
  };
11
+
12
+ // src/adapters/tcp/user.tcp.adapter.ts
13
+ import { config } from "dotenv";
14
+ import { Transport } from "@nestjs/microservices";
15
+ config();
16
+ var UserTCPAdapter = () => {
17
+ return {
18
+ name: "USER_MICROSERVICE",
19
+ transport: Transport.TCP,
20
+ options: {
21
+ host: process.env.USER_MICROSERVICE_TCP_HOST || "localhost",
22
+ port: parseInt(process.env.USER_MICROSERVICE_TCP_PORT || "4001", 10)
23
+ }
24
+ };
25
+ };
26
+
27
+ // src/adapters/rmq/user.rmq.adapter.ts
28
+ import { config as config2 } from "dotenv";
29
+ import { Transport as Transport2 } from "@nestjs/microservices";
30
+ config2();
31
+ var UserRMQAdapter = (mode = "microservice") => {
32
+ const urls = process.env.USER_MICROSERVICE_RMQ_URL?.split(",") || [
33
+ "amqp://localhost:5672"
34
+ ];
35
+ const queue = process.env.USER_MICROSERVICE_RMQ_QUEUE || "user_queue";
36
+ const prefetchCount = parseInt(
37
+ process.env.USER_MICROSERVICE_RMQ_PREFETCH_COUNT || "10"
38
+ );
39
+ const heartbeat = parseInt(
40
+ process.env.USER_MICROSERVICE_RMQ_HEARTBEAT || "60"
41
+ );
42
+ const deadLetterExchange = process.env.USER_MICROSERVICE_RMQ_DLX || "user_dlx";
43
+ const deadLetterQueue = process.env.USER_MICROSERVICE_RMQ_DLQ || "user_dlq";
44
+ const messageTtl = parseInt(
45
+ process.env.USER_MICROSERVICE_RMQ_MESSAGE_TTL || "30000"
46
+ );
47
+ const config3 = {
48
+ name: "USER_MICROSERVICE",
49
+ transport: Transport2.RMQ,
50
+ options: {
51
+ urls,
52
+ queue,
53
+ prefetchCount,
54
+ heartbeat,
55
+ queueOptions: {
56
+ durable: true,
57
+ arguments: {
58
+ "x-dead-letter-exchange": deadLetterExchange,
59
+ "x-dead-letter-routing-key": deadLetterQueue,
60
+ "x-message-ttl": messageTtl
61
+ }
62
+ },
63
+ connectionOptions: {
64
+ heartbeat,
65
+ retry: true,
66
+ retryAttempts: 5,
67
+ retryDelay: 3e3,
68
+ timeout: 1e4,
69
+ poolSize: parseInt(process.env.MICROSERVICE_RMQ_POOL_SIZE || "5"),
70
+ ...process.env.USER_MICROSERVICE_RMQ_USE_SSL === "true" && {
71
+ ssl: {
72
+ rejectUnauthorized: false
73
+ }
74
+ }
75
+ }
76
+ }
77
+ };
78
+ if (mode === "microservice") {
79
+ config3["options"]["noAck"] = false;
80
+ }
81
+ return config3;
82
+ };
11
83
  export {
12
- AUTHENTICATION_PATTERN
84
+ AUTHENTICATION_PATTERN,
85
+ UserRMQAdapter,
86
+ UserTCPAdapter
13
87
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@experts_hub/shared",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "description": "Shared DTOs, interfaces, and utilities for experts hub applications",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",