@fiado/api-invoker 1.0.14 → 1.0.15

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,64 +1,64 @@
1
- # fiado-api-invoker
2
-
3
- `fiado-api-invoker` es una librería diseñada para facilitar la invocación de APIs privadas de AWS Lambda a través de API Gateway dentro de la misma VPC. Esta librería simplifica el proceso de configuración y llamada a servicios, permitiendo a los desarrolladores centrarse en la lógica de negocio.
4
-
5
-
6
- ## Configuración
7
-
8
- Antes de usar la librería, asegúrate de configurar la URL base del API Gateway privado que corresponda por ejemplo si vas a usar los servicios del Lambda `Directory` se puede hacer estableciendo la variable de entorno `DIRECTORY_LAMBDA_URL`.
9
-
10
-
11
- ## Instalación
12
- ```bash
13
- `npm install fiado-api-invoker @fiado/http-client`
14
- ```
15
-
16
- ## Configuración del Contenedor de InversifyJS
17
-
18
- ```typescript
19
- import { Container } from "inversify";
20
- import { IHttpRequest, AxiosHttpRequest } from "@fiado/http-client";
21
- import { apiInvokerContainer } from '@fiado/api-invoker';
22
-
23
- // Crea el contenedor principal de tu aplicación
24
- const container = new Container();
25
-
26
- // Aplica las configuraciones de vinculación de fiado-gateway-adapter al contenedor
27
- container.load(gatewayAdapterBindings);
28
-
29
- // Registro del cliente HTTP
30
- container.bind<IHttpRequest>("IHttpRequest").to(AxiosHttpRequest);
31
-
32
- // Exporta el contenedor para su uso en toda tu aplicación
33
- export { container };
34
-
35
-
36
- ```
37
-
38
-
39
- ## Uso de IDirectoryApi en Servicios del Proyecto
40
-
41
- Para utilizar `fiado-api-invoker`, necesitas configurar el contenedor de InversifyJS en tu aplicación. Aquí te mostramos cómo registrar las dependencias necesarias:
42
-
43
- ```typescript
44
- import { inject, injectable } from "inversify";
45
- import { IDirectoryApi } from "fiado-api-invoker";
46
- import { log } from "@fiado/logger";
47
-
48
- @injectable()
49
- export class SomeService {
50
- constructor(@inject("IDirectoryApi") private directoryApi: IDirectoryApi) {}
51
-
52
- public async fetchDirectoryDetails(directoryIds: string[]): Promise<void> {
53
- try {
54
- const details = await this.directoryApi.getByIds(directoryIds);
55
- log.info(details);
56
-
57
- } catch (error) {
58
- log.error("Error fetching directory details:", error);
59
- }
60
- }
61
- }
62
- ```
63
-
64
-
1
+ # fiado-api-invoker
2
+
3
+ `fiado-api-invoker` es una librería diseñada para facilitar la invocación de APIs privadas de AWS Lambda a través de API Gateway dentro de la misma VPC. Esta librería simplifica el proceso de configuración y llamada a servicios, permitiendo a los desarrolladores centrarse en la lógica de negocio.
4
+
5
+
6
+ ## Configuración
7
+
8
+ Antes de usar la librería, asegúrate de configurar la URL base del API Gateway privado que corresponda por ejemplo si vas a usar los servicios del Lambda `Directory` se puede hacer estableciendo la variable de entorno `DIRECTORY_LAMBDA_URL`.
9
+
10
+
11
+ ## Instalación
12
+ ```bash
13
+ `npm install fiado-api-invoker @fiado/http-client`
14
+ ```
15
+
16
+ ## Configuración del Contenedor de InversifyJS
17
+
18
+ ```typescript
19
+ import { Container } from "inversify";
20
+ import { IHttpRequest, AxiosHttpRequest } from "@fiado/http-client";
21
+ import { apiInvokerContainer } from '@fiado/api-invoker';
22
+
23
+ // Crea el contenedor principal de tu aplicación
24
+ const container = new Container();
25
+
26
+ // Aplica las configuraciones de vinculación de fiado-gateway-adapter al contenedor
27
+ container.load(gatewayAdapterBindings);
28
+
29
+ // Registro del cliente HTTP
30
+ container.bind<IHttpRequest>("IHttpRequest").to(AxiosHttpRequest);
31
+
32
+ // Exporta el contenedor para su uso en toda tu aplicación
33
+ export { container };
34
+
35
+
36
+ ```
37
+
38
+
39
+ ## Uso de IDirectoryApi en Servicios del Proyecto
40
+
41
+ Para utilizar `fiado-api-invoker`, necesitas configurar el contenedor de InversifyJS en tu aplicación. Aquí te mostramos cómo registrar las dependencias necesarias:
42
+
43
+ ```typescript
44
+ import { inject, injectable } from "inversify";
45
+ import { IDirectoryApi } from "fiado-api-invoker";
46
+ import { log } from "@fiado/logger";
47
+
48
+ @injectable()
49
+ export class SomeService {
50
+ constructor(@inject("IDirectoryApi") private directoryApi: IDirectoryApi) {}
51
+
52
+ public async fetchDirectoryDetails(directoryIds: string[]): Promise<void> {
53
+ try {
54
+ const details = await this.directoryApi.getByIds(directoryIds);
55
+ log.info(details);
56
+
57
+ } catch (error) {
58
+ log.error("Error fetching directory details:", error);
59
+ }
60
+ }
61
+ }
62
+ ```
63
+
64
+
package/bin/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export * from './directory';
2
2
  export * from './identity';
3
+ export * from './notificationMessages';
4
+ export * from './sessionActivity';
3
5
  export * from "./container.config";
package/bin/index.js CHANGED
@@ -16,4 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./directory"), exports);
18
18
  __exportStar(require("./identity"), exports);
19
+ __exportStar(require("./notificationMessages"), exports);
20
+ __exportStar(require("./sessionActivity"), exports);
19
21
  __exportStar(require("./container.config"), exports);
@@ -0,0 +1,2 @@
1
+ export * from './queue/NotificationMessagePublisher';
2
+ export * from './queue/interfaces/INotificationMessagesPublisher';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./queue/NotificationMessagePublisher"), exports);
18
+ __exportStar(require("./queue/interfaces/INotificationMessagesPublisher"), exports);
@@ -0,0 +1,2 @@
1
+ export * from './queue/SessionActivityPublisher';
2
+ export * from './queue/interfaces/ISessionActivityPublisher';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./queue/SessionActivityPublisher"), exports);
18
+ __exportStar(require("./queue/interfaces/ISessionActivityPublisher"), exports);
@@ -0,0 +1,6 @@
1
+ import { ISessionActivityPublisher } from "./interfaces/ISessionActivityPublisher";
2
+ import { SessionActivityQueueMessageRequest } from "@fiado/type-kit/bin/sessionActivity";
3
+ export declare class SessionActivityPublisher implements ISessionActivityPublisher {
4
+ private readonly SESSION_ACTIVITY_QUEUE;
5
+ publish(message: SessionActivityQueueMessageRequest): Promise<void>;
6
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SessionActivityPublisher = void 0;
4
+ const client_sqs_1 = require("@aws-sdk/client-sqs");
5
+ class SessionActivityPublisher {
6
+ constructor() {
7
+ this.SESSION_ACTIVITY_QUEUE = process.env.SESSION_ACTIVITY_QUEUE;
8
+ }
9
+ async publish(message) {
10
+ try {
11
+ const client = new client_sqs_1.SQSClient();
12
+ const sendMessageRequest = {
13
+ QueueUrl: this.SESSION_ACTIVITY_QUEUE,
14
+ MessageBody: JSON.stringify(message)
15
+ };
16
+ const command = new client_sqs_1.SendMessageCommand(sendMessageRequest);
17
+ await client.send(command);
18
+ }
19
+ catch (error) {
20
+ throw new Error(`Error publishing message to queue ${': ' + error.message ?? ''}`);
21
+ }
22
+ }
23
+ }
24
+ exports.SessionActivityPublisher = SessionActivityPublisher;
@@ -0,0 +1,4 @@
1
+ import { SessionActivityQueueMessageRequest } from "@fiado/type-kit/bin/sessionActivity";
2
+ export interface ISessionActivityPublisher {
3
+ publish(message: SessionActivityQueueMessageRequest): Promise<void>;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
- {
2
- "name": "@fiado/api-invoker",
3
- "version": "1.0.14",
4
- "description": "Sirve como un puente entre diferentes funciones lambda, facilitando la comunicación entre ellas a traves de invocaciones http",
5
- "main": "bin/index.js",
6
- "types": "bin/index.d.ts",
7
- "scripts": {
8
- "test": "test",
9
- "build": "tsc"
10
- },
11
- "keywords": [],
12
- "author": "Fiado Inc",
13
- "license": "ISC",
14
- "dependencies": {
15
- "@aws-sdk/client-sqs": "^3.572.0",
16
- "@fiado/api-invoker": "^1.0.5",
17
- "@fiado/gateway-adapter": "^1.0.30",
18
- "@fiado/http-client": "^1.0.1",
19
- "@fiado/type-kit": "^1.0.38",
20
- "dotenv": "^16.4.5",
21
- "inversify": "^6.0.2",
22
- "reflect-metadata": "^0.2.1",
23
- "typescript": "^5.4.3"
24
- },
25
- "devDependencies": {
26
- "@types/node": "^20.12.7"
27
- }
28
- }
1
+ {
2
+ "name": "@fiado/api-invoker",
3
+ "version": "1.0.15",
4
+ "description": "Sirve como un puente entre diferentes funciones lambda, facilitando la comunicación entre ellas a traves de invocaciones http",
5
+ "main": "bin/index.js",
6
+ "types": "bin/index.d.ts",
7
+ "scripts": {
8
+ "test": "test",
9
+ "build": "tsc"
10
+ },
11
+ "keywords": [],
12
+ "author": "Fiado Inc",
13
+ "license": "ISC",
14
+ "dependencies": {
15
+ "@aws-sdk/client-sqs": "^3.572.0",
16
+ "@fiado/api-invoker": "^1.0.5",
17
+ "@fiado/gateway-adapter": "^1.0.30",
18
+ "@fiado/http-client": "^1.0.1",
19
+ "@fiado/type-kit": "^1.0.39",
20
+ "dotenv": "^16.4.5",
21
+ "inversify": "^6.0.2",
22
+ "reflect-metadata": "^0.2.1",
23
+ "typescript": "^5.4.3"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^20.12.7"
27
+ }
28
+ }
@@ -1,11 +1,11 @@
1
- import {ContainerModule, interfaces} from "inversify";
2
- import {DirectoryApi, IDirectoryApi} from "./directory";
3
- import {IdentityApi, IIdentityApi} from "./identity";
4
- import {INotificationMessagesPublisher} from "./notificationMessages/queue/interfaces/INotificationMessagesPublisher";
5
- import NotificationMessagePublisher from "./notificationMessages/queue/NotificationMessagePublisher";
6
-
7
- export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) => {
8
- bind<IDirectoryApi>("IDirectoryApi").to(DirectoryApi);
9
- bind<IIdentityApi>("IIdentityApi").to(IdentityApi);
10
- bind<INotificationMessagesPublisher>("INotificationMessagesPublisher").to(NotificationMessagePublisher);
11
- });
1
+ import {ContainerModule, interfaces} from "inversify";
2
+ import {DirectoryApi, IDirectoryApi} from "./directory";
3
+ import {IdentityApi, IIdentityApi} from "./identity";
4
+ import {INotificationMessagesPublisher} from "./notificationMessages/queue/interfaces/INotificationMessagesPublisher";
5
+ import NotificationMessagePublisher from "./notificationMessages/queue/NotificationMessagePublisher";
6
+
7
+ export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) => {
8
+ bind<IDirectoryApi>("IDirectoryApi").to(DirectoryApi);
9
+ bind<IIdentityApi>("IIdentityApi").to(IdentityApi);
10
+ bind<INotificationMessagesPublisher>("INotificationMessagesPublisher").to(NotificationMessagePublisher);
11
+ });
@@ -1,25 +1,25 @@
1
- import { inject, injectable } from "inversify";
2
- import { IDirectoryApi } from "./interfaces/IDirectoryApi";
3
- import { IHttpRequest } from "@fiado/http-client";
4
- import dotenv from 'dotenv';
5
- dotenv.config();
6
-
7
- @injectable()
8
- export class DirectoryApi implements IDirectoryApi {
9
-
10
- private readonly baseUrl = process.env.DIRECTORY_LAMBDA_URL || "";
11
-
12
- constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) { }
13
-
14
- public async getByIds(ids: string[]): Promise<any> {
15
-
16
- if (ids.length === 0) {
17
- throw new Error("At least one directory ID is required.")
18
- }
19
-
20
- const url = `${this.baseUrl}?${ids.map(id => `directoryId=${encodeURIComponent(id)}`).join('&')}`;
21
- const operationName = "getUserInfoByIds";
22
-
23
- return await this.httpRequest.post(`${url}`, null, { 'operationName': operationName });
24
- }
25
- }
1
+ import { inject, injectable } from "inversify";
2
+ import { IDirectoryApi } from "./interfaces/IDirectoryApi";
3
+ import { IHttpRequest } from "@fiado/http-client";
4
+ import dotenv from 'dotenv';
5
+ dotenv.config();
6
+
7
+ @injectable()
8
+ export class DirectoryApi implements IDirectoryApi {
9
+
10
+ private readonly baseUrl = process.env.DIRECTORY_LAMBDA_URL || "";
11
+
12
+ constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) { }
13
+
14
+ public async getByIds(ids: string[]): Promise<any> {
15
+
16
+ if (ids.length === 0) {
17
+ throw new Error("At least one directory ID is required.")
18
+ }
19
+
20
+ const url = `${this.baseUrl}?${ids.map(id => `directoryId=${encodeURIComponent(id)}`).join('&')}`;
21
+ const operationName = "getUserInfoByIds";
22
+
23
+ return await this.httpRequest.post(`${url}`, null, { 'operationName': operationName });
24
+ }
25
+ }
@@ -1,3 +1,3 @@
1
-
2
- export * from './interfaces/IDirectoryApi';
3
- export * from './DirectoryApi';
1
+
2
+ export * from './interfaces/IDirectoryApi';
3
+ export * from './DirectoryApi';
@@ -1,14 +1,14 @@
1
-
2
- /**
3
- * Interfaz para el servicio Directory que permite operaciones sobre directorios.
4
- */
5
- export interface IDirectoryApi {
6
- /**
7
- * Obtiene una lista de directorios por sus IDs.
8
- * @param ids Array de IDs de directorios (UUIDs) a buscar.
9
- * @returns Una promesa que resuelve a un arreglo de objetos de directorio.
10
- * Puede devolver un arreglo vacío si no se encuentran coincidencias.
11
- * @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
12
- */
13
- getByIds(ids: string[]): Promise<any>;
14
- }
1
+
2
+ /**
3
+ * Interfaz para el servicio Directory que permite operaciones sobre directorios.
4
+ */
5
+ export interface IDirectoryApi {
6
+ /**
7
+ * Obtiene una lista de directorios por sus IDs.
8
+ * @param ids Array de IDs de directorios (UUIDs) a buscar.
9
+ * @returns Una promesa que resuelve a un arreglo de objetos de directorio.
10
+ * Puede devolver un arreglo vacío si no se encuentran coincidencias.
11
+ * @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
12
+ */
13
+ getByIds(ids: string[]): Promise<any>;
14
+ }
@@ -1,25 +1,25 @@
1
- import { inject, injectable } from "inversify";
2
- import { IIdentityApi } from "./interfaces/IIdentityApi";
3
- import { IHttpRequest } from "@fiado/http-client";
4
- import dotenv from 'dotenv';
5
- dotenv.config();
6
-
7
- @injectable()
8
- export class IdentityApi implements IIdentityApi {
9
-
10
- private readonly baseUrl = process.env.IDENTITY_LAMBDA_URL || "";
11
-
12
- constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) { }
13
-
14
- async getPeopleByIds(ids: string[]): Promise<any> {
15
-
16
- if (ids.length === 0) {
17
- throw new Error("At least one people ID is required.")
18
- }
19
-
20
- const url = `${this.baseUrl}identities/people?${ids.map(id => `id=${encodeURIComponent(id)}`).join('&')}`;
21
-
22
- return await this.httpRequest.get(`${url}`);
23
-
24
- }
1
+ import { inject, injectable } from "inversify";
2
+ import { IIdentityApi } from "./interfaces/IIdentityApi";
3
+ import { IHttpRequest } from "@fiado/http-client";
4
+ import dotenv from 'dotenv';
5
+ dotenv.config();
6
+
7
+ @injectable()
8
+ export class IdentityApi implements IIdentityApi {
9
+
10
+ private readonly baseUrl = process.env.IDENTITY_LAMBDA_URL || "";
11
+
12
+ constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) { }
13
+
14
+ async getPeopleByIds(ids: string[]): Promise<any> {
15
+
16
+ if (ids.length === 0) {
17
+ throw new Error("At least one people ID is required.")
18
+ }
19
+
20
+ const url = `${this.baseUrl}identities/people?${ids.map(id => `id=${encodeURIComponent(id)}`).join('&')}`;
21
+
22
+ return await this.httpRequest.get(`${url}`);
23
+
24
+ }
25
25
  }
@@ -1,4 +1,4 @@
1
-
2
-
3
- export * from './interfaces/IIdentityApi';
1
+
2
+
3
+ export * from './interfaces/IIdentityApi';
4
4
  export * from './IdentityApi';
@@ -1,14 +1,14 @@
1
-
2
- /**
3
- * Interfaz para el servicio Directory que permite operaciones sobre directorios.
4
- */
5
- export interface IIdentityApi {
6
- /**
7
- * Obtiene una lista de people por sus IDs.
8
- * @param ids Array de IDs de peopleId (UUIDs) a buscar.
9
- * @returns Una promesa que resuelve a un arreglo de objetos de people.
10
- * Puede devolver un arreglo vacío si no se encuentran coincidencias.
11
- * @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
12
- */
13
- getPeopleByIds(ids: string[]): Promise<any>;
14
- }
1
+
2
+ /**
3
+ * Interfaz para el servicio Directory que permite operaciones sobre directorios.
4
+ */
5
+ export interface IIdentityApi {
6
+ /**
7
+ * Obtiene una lista de people por sus IDs.
8
+ * @param ids Array de IDs de peopleId (UUIDs) a buscar.
9
+ * @returns Una promesa que resuelve a un arreglo de objetos de people.
10
+ * Puede devolver un arreglo vacío si no se encuentran coincidencias.
11
+ * @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
12
+ */
13
+ getPeopleByIds(ids: string[]): Promise<any>;
14
+ }
package/src/index.ts CHANGED
@@ -1,11 +1,9 @@
1
-
2
-
3
-
4
- export * from './directory';
5
- export * from './identity';
6
-
7
-
8
- export * from "./container.config";
9
-
10
-
11
-
1
+ export * from './directory';
2
+ export * from './identity';
3
+ export * from './notificationMessages';
4
+ export * from './sessionActivity';
5
+
6
+ export * from "./container.config";
7
+
8
+
9
+
@@ -0,0 +1,2 @@
1
+ export * from './queue/NotificationMessagePublisher';
2
+ export * from './queue/interfaces/INotificationMessagesPublisher';
@@ -1,23 +1,23 @@
1
- import {INotificationMessagesPublisher} from "./interfaces/INotificationMessagesPublisher";
2
- import {NotificationQueueMessageRequest} from "@fiado/type-kit/bin/notificationMessages";
3
- import {SendMessageCommand, SendMessageRequest, SQSClient} from "@aws-sdk/client-sqs";
4
- import {injectable} from "inversify";
5
-
6
- @injectable()
7
- export default class NotificationMessagePublisher implements INotificationMessagesPublisher {
8
- private readonly NOTIFICATION_MESSAGES_QUEUE = process.env.NOTIFICATION_MESSAGES_QUEUE
9
-
10
- async publish(message: NotificationQueueMessageRequest): Promise<void> {
11
- try {
12
- const client: SQSClient = new SQSClient();
13
- const sendMessageRequest: SendMessageRequest = {
14
- QueueUrl: this.NOTIFICATION_MESSAGES_QUEUE,
15
- MessageBody: JSON.stringify(message)
16
- };
17
- const command: SendMessageCommand = new SendMessageCommand(sendMessageRequest);
18
- await client.send(command);
19
- } catch (error) {
20
- throw new Error(`Error publishing message to queue ${': ' + error.message ?? ''}`);
21
- }
22
- }
1
+ import {INotificationMessagesPublisher} from "./interfaces/INotificationMessagesPublisher";
2
+ import {NotificationQueueMessageRequest} from "@fiado/type-kit/bin/notificationMessages";
3
+ import {SendMessageCommand, SendMessageRequest, SQSClient} from "@aws-sdk/client-sqs";
4
+ import {injectable} from "inversify";
5
+
6
+ @injectable()
7
+ export default class NotificationMessagePublisher implements INotificationMessagesPublisher {
8
+ private readonly NOTIFICATION_MESSAGES_QUEUE = process.env.NOTIFICATION_MESSAGES_QUEUE
9
+
10
+ async publish(message: NotificationQueueMessageRequest): Promise<void> {
11
+ try {
12
+ const client: SQSClient = new SQSClient();
13
+ const sendMessageRequest: SendMessageRequest = {
14
+ QueueUrl: this.NOTIFICATION_MESSAGES_QUEUE,
15
+ MessageBody: JSON.stringify(message)
16
+ };
17
+ const command: SendMessageCommand = new SendMessageCommand(sendMessageRequest);
18
+ await client.send(command);
19
+ } catch (error) {
20
+ throw new Error(`Error publishing message to queue ${': ' + error.message ?? ''}`);
21
+ }
22
+ }
23
23
  }
@@ -1,5 +1,5 @@
1
- import {NotificationQueueMessageRequest} from "@fiado/type-kit/bin/notificationMessages";
2
-
3
- export interface INotificationMessagesPublisher {
4
- publish(message: NotificationQueueMessageRequest): Promise<void>;
1
+ import {NotificationQueueMessageRequest} from "@fiado/type-kit/bin/notificationMessages";
2
+
3
+ export interface INotificationMessagesPublisher {
4
+ publish(message: NotificationQueueMessageRequest): Promise<void>;
5
5
  }
@@ -0,0 +1,2 @@
1
+ export * from './queue/SessionActivityPublisher';
2
+ export * from './queue/interfaces/ISessionActivityPublisher';
@@ -0,0 +1,21 @@
1
+ import {SendMessageCommand, SendMessageRequest, SQSClient} from "@aws-sdk/client-sqs";
2
+ import {ISessionActivityPublisher} from "./interfaces/ISessionActivityPublisher";
3
+ import {SessionActivityQueueMessageRequest} from "@fiado/type-kit/bin/sessionActivity";
4
+
5
+ export class SessionActivityPublisher implements ISessionActivityPublisher {
6
+ private readonly SESSION_ACTIVITY_QUEUE = process.env.SESSION_ACTIVITY_QUEUE
7
+
8
+ async publish(message: SessionActivityQueueMessageRequest): Promise<void> {
9
+ try {
10
+ const client: SQSClient = new SQSClient();
11
+ const sendMessageRequest: SendMessageRequest = {
12
+ QueueUrl: this.SESSION_ACTIVITY_QUEUE,
13
+ MessageBody: JSON.stringify(message)
14
+ };
15
+ const command: SendMessageCommand = new SendMessageCommand(sendMessageRequest);
16
+ await client.send(command);
17
+ } catch (error) {
18
+ throw new Error(`Error publishing message to queue ${': ' + error.message ?? ''}`);
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,5 @@
1
+ import {SessionActivityQueueMessageRequest} from "@fiado/type-kit/bin/sessionActivity";
2
+
3
+ export interface ISessionActivityPublisher {
4
+ publish(message: SessionActivityQueueMessageRequest): Promise<void>;
5
+ }
package/tsconfig.json CHANGED
@@ -1,21 +1,21 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "commonjs",
5
- "esModuleInterop": true,
6
- "skipLibCheck": true,
7
- "forceConsistentCasingInFileNames": true,
8
- "experimentalDecorators": true,
9
- "emitDecoratorMetadata": true,
10
- "outDir": "./bin",
11
- "rootDir": "./src",
12
- "moduleResolution": "node",
13
- "declaration": true,
14
- },
15
- "include": [
16
- "./src/**/*"
17
- ],
18
- "exclude": [
19
- "node_modules"
20
- ]
21
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "commonjs",
5
+ "esModuleInterop": true,
6
+ "skipLibCheck": true,
7
+ "forceConsistentCasingInFileNames": true,
8
+ "experimentalDecorators": true,
9
+ "emitDecoratorMetadata": true,
10
+ "outDir": "./bin",
11
+ "rootDir": "./src",
12
+ "moduleResolution": "node",
13
+ "declaration": true,
14
+ },
15
+ "include": [
16
+ "./src/**/*"
17
+ ],
18
+ "exclude": [
19
+ "node_modules"
20
+ ]
21
+ }