@fiado/api-invoker 1.0.12 → 1.0.14
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/bin/container.config.js +7 -2
- package/bin/identity/IdentityApi.js +1 -1
- package/bin/notificationMessages/queue/NotificationMessagePublisher.d.ts +6 -0
- package/bin/notificationMessages/queue/NotificationMessagePublisher.js +33 -0
- package/bin/notificationMessages/queue/interfaces/INotificationMessagesPublisher.d.ts +4 -0
- package/bin/notificationMessages/queue/interfaces/INotificationMessagesPublisher.js +2 -0
- package/package.json +3 -2
- package/src/container.config.ts +6 -5
- package/src/identity/IdentityApi.ts +1 -1
- package/src/notificationMessages/queue/NotificationMessagePublisher.ts +23 -0
- package/src/notificationMessages/queue/interfaces/INotificationMessagesPublisher.ts +5 -0
package/bin/container.config.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.apiInvokerBindings = void 0;
|
|
4
7
|
const inversify_1 = require("inversify");
|
|
5
8
|
const directory_1 = require("./directory");
|
|
6
|
-
const
|
|
9
|
+
const identity_1 = require("./identity");
|
|
10
|
+
const NotificationMessagePublisher_1 = __importDefault(require("./notificationMessages/queue/NotificationMessagePublisher"));
|
|
7
11
|
exports.apiInvokerBindings = new inversify_1.ContainerModule((bind) => {
|
|
8
12
|
bind("IDirectoryApi").to(directory_1.DirectoryApi);
|
|
9
|
-
bind("IIdentityApi").to(
|
|
13
|
+
bind("IIdentityApi").to(identity_1.IdentityApi);
|
|
14
|
+
bind("INotificationMessagesPublisher").to(NotificationMessagePublisher_1.default);
|
|
10
15
|
});
|
|
@@ -29,7 +29,7 @@ let IdentityApi = class IdentityApi {
|
|
|
29
29
|
throw new Error("At least one people ID is required.");
|
|
30
30
|
}
|
|
31
31
|
const url = `${this.baseUrl}identities/people?${ids.map(id => `id=${encodeURIComponent(id)}`).join('&')}`;
|
|
32
|
-
return await this.httpRequest.
|
|
32
|
+
return await this.httpRequest.get(`${url}`);
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
exports.IdentityApi = IdentityApi;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { INotificationMessagesPublisher } from "./interfaces/INotificationMessagesPublisher";
|
|
2
|
+
import { NotificationQueueMessageRequest } from "@fiado/type-kit/bin/notificationMessages";
|
|
3
|
+
export default class NotificationMessagePublisher implements INotificationMessagesPublisher {
|
|
4
|
+
private readonly NOTIFICATION_MESSAGES_QUEUE;
|
|
5
|
+
publish(message: NotificationQueueMessageRequest): Promise<void>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const client_sqs_1 = require("@aws-sdk/client-sqs");
|
|
10
|
+
const inversify_1 = require("inversify");
|
|
11
|
+
let NotificationMessagePublisher = class NotificationMessagePublisher {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.NOTIFICATION_MESSAGES_QUEUE = process.env.NOTIFICATION_MESSAGES_QUEUE;
|
|
14
|
+
}
|
|
15
|
+
async publish(message) {
|
|
16
|
+
try {
|
|
17
|
+
const client = new client_sqs_1.SQSClient();
|
|
18
|
+
const sendMessageRequest = {
|
|
19
|
+
QueueUrl: this.NOTIFICATION_MESSAGES_QUEUE,
|
|
20
|
+
MessageBody: JSON.stringify(message)
|
|
21
|
+
};
|
|
22
|
+
const command = new client_sqs_1.SendMessageCommand(sendMessageRequest);
|
|
23
|
+
await client.send(command);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
throw new Error(`Error publishing message to queue ${': ' + error.message ?? ''}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
NotificationMessagePublisher = __decorate([
|
|
31
|
+
(0, inversify_1.injectable)()
|
|
32
|
+
], NotificationMessagePublisher);
|
|
33
|
+
exports.default = NotificationMessagePublisher;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiado/api-invoker",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "Sirve como un puente entre diferentes funciones lambda, facilitando la comunicación entre ellas a traves de invocaciones http",
|
|
5
5
|
"main": "bin/index.js",
|
|
6
6
|
"types": "bin/index.d.ts",
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
"author": "Fiado Inc",
|
|
13
13
|
"license": "ISC",
|
|
14
14
|
"dependencies": {
|
|
15
|
+
"@aws-sdk/client-sqs": "^3.572.0",
|
|
15
16
|
"@fiado/api-invoker": "^1.0.5",
|
|
16
17
|
"@fiado/gateway-adapter": "^1.0.30",
|
|
17
18
|
"@fiado/http-client": "^1.0.1",
|
|
18
|
-
"@fiado/type-kit": "^1.0.
|
|
19
|
+
"@fiado/type-kit": "^1.0.38",
|
|
19
20
|
"dotenv": "^16.4.5",
|
|
20
21
|
"inversify": "^6.0.2",
|
|
21
22
|
"reflect-metadata": "^0.2.1",
|
package/src/container.config.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
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
6
|
|
|
7
7
|
export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) => {
|
|
8
8
|
bind<IDirectoryApi>("IDirectoryApi").to(DirectoryApi);
|
|
9
9
|
bind<IIdentityApi>("IIdentityApi").to(IdentityApi);
|
|
10
|
+
bind<INotificationMessagesPublisher>("INotificationMessagesPublisher").to(NotificationMessagePublisher);
|
|
10
11
|
});
|
|
@@ -19,7 +19,7 @@ export class IdentityApi implements IIdentityApi {
|
|
|
19
19
|
|
|
20
20
|
const url = `${this.baseUrl}identities/people?${ids.map(id => `id=${encodeURIComponent(id)}`).join('&')}`;
|
|
21
21
|
|
|
22
|
-
return await this.httpRequest.
|
|
22
|
+
return await this.httpRequest.get(`${url}`);
|
|
23
23
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -0,0 +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
|
+
}
|
|
23
|
+
}
|