@fiado/api-invoker 1.0.5 → 1.0.6
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
|
@@ -9,22 +9,22 @@ Antes de usar la librería, asegúrate de configurar la URL base del API Gateway
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
## Instalación
|
|
12
|
-
|
|
13
|
-
npm install fiado-api-invoker @fiado/http-client
|
|
12
|
+
```bash
|
|
13
|
+
`npm install fiado-api-invoker @fiado/http-client`
|
|
14
|
+
```
|
|
14
15
|
|
|
15
16
|
## Configuración del Contenedor de InversifyJS
|
|
16
17
|
|
|
17
18
|
```typescript
|
|
18
19
|
import { Container } from "inversify";
|
|
19
|
-
import { apiInvokerContainer } from '@fiado/api-invoker';
|
|
20
20
|
import { IHttpRequest, AxiosHttpRequest } from "@fiado/http-client";
|
|
21
|
+
import { apiInvokerContainer } from '@fiado/api-invoker';
|
|
21
22
|
|
|
22
23
|
// Crea el contenedor principal de tu aplicación
|
|
23
24
|
const container = new Container();
|
|
24
25
|
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
container.parent = apiInvokerContainer;
|
|
26
|
+
// Aplica las configuraciones de vinculación de fiado-gateway-adapter al contenedor
|
|
27
|
+
container.load(gatewayAdapterBindings);
|
|
28
28
|
|
|
29
29
|
// Registro del cliente HTTP
|
|
30
30
|
container.bind<IHttpRequest>("IHttpRequest").to(AxiosHttpRequest);
|
|
@@ -32,6 +32,7 @@ container.bind<IHttpRequest>("IHttpRequest").to(AxiosHttpRequest);
|
|
|
32
32
|
// Exporta el contenedor para su uso en toda tu aplicación
|
|
33
33
|
export { container };
|
|
34
34
|
|
|
35
|
+
|
|
35
36
|
```
|
|
36
37
|
|
|
37
38
|
|
|
@@ -52,7 +53,7 @@ export class SomeService {
|
|
|
52
53
|
try {
|
|
53
54
|
const details = await this.directoryApi.getByIds(directoryIds);
|
|
54
55
|
log.info(details);
|
|
55
|
-
|
|
56
|
+
|
|
56
57
|
} catch (error) {
|
|
57
58
|
log.error("Error fetching directory details:", error);
|
|
58
59
|
}
|
|
@@ -11,9 +11,14 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
14
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
18
|
exports.DirectoryApi = void 0;
|
|
16
19
|
const inversify_1 = require("inversify");
|
|
20
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
21
|
+
dotenv_1.default.config();
|
|
17
22
|
let DirectoryApi = class DirectoryApi {
|
|
18
23
|
constructor(httpRequest) {
|
|
19
24
|
this.httpRequest = httpRequest;
|
|
@@ -25,7 +30,7 @@ let DirectoryApi = class DirectoryApi {
|
|
|
25
30
|
}
|
|
26
31
|
const queryParams = ids.map(id => `directoryId=${id}`).join('&');
|
|
27
32
|
const operationName = "getUserInfoByIds";
|
|
28
|
-
return await this.httpRequest.
|
|
33
|
+
return await this.httpRequest.post(`${this.baseUrl}/`, { params: queryParams, headers: { 'operationName': operationName } });
|
|
29
34
|
}
|
|
30
35
|
};
|
|
31
36
|
exports.DirectoryApi = DirectoryApi;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiado/api-invoker",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
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,11 +12,16 @@
|
|
|
12
12
|
"author": "Fiado Inc",
|
|
13
13
|
"license": "ISC",
|
|
14
14
|
"dependencies": {
|
|
15
|
+
"@fiado/api-invoker": "^1.0.5",
|
|
16
|
+
"@fiado/gateway-adapter": "^1.0.30",
|
|
17
|
+
"@fiado/http-client": "^1.0.1",
|
|
15
18
|
"@fiado/type-kit": "^1.0.16",
|
|
19
|
+
"dotenv": "^16.4.5",
|
|
16
20
|
"inversify": "^6.0.2",
|
|
17
21
|
"reflect-metadata": "^0.2.1",
|
|
18
22
|
"typescript": "^5.4.3"
|
|
19
23
|
},
|
|
20
24
|
"devDependencies": {
|
|
25
|
+
"@types/node": "^20.12.7"
|
|
21
26
|
}
|
|
22
|
-
}
|
|
27
|
+
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { inject, injectable } from "inversify";
|
|
3
3
|
import { IDirectoryApi } from "./interfaces/IDirectoryApi";
|
|
4
4
|
import { IHttpRequest } from "@fiado/http-client";
|
|
5
|
+
import dotenv from 'dotenv';
|
|
6
|
+
dotenv.config();
|
|
5
7
|
|
|
6
8
|
@injectable()
|
|
7
9
|
export class DirectoryApi implements IDirectoryApi {
|
|
@@ -19,6 +21,6 @@ export class DirectoryApi implements IDirectoryApi {
|
|
|
19
21
|
const queryParams = ids.map(id => `directoryId=${id}`).join('&');
|
|
20
22
|
const operationName = "getUserInfoByIds";
|
|
21
23
|
|
|
22
|
-
return await this.httpRequest.
|
|
24
|
+
return await this.httpRequest.post(`${this.baseUrl}/`, { params: queryParams, headers: { 'operationName': operationName } });
|
|
23
25
|
}
|
|
24
26
|
}
|