@omegasolutions/vallora-log-sdk 1.0.1 → 1.2.0
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 +30 -19
- package/dist/log-client.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,29 +1,40 @@
|
|
|
1
1
|
# README #
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Este sdk será utilizado para importar nos projetos do vallora, com o objetivo de simplificar a interface com o serviço de logs https://bitbucket.org/omegasolutionssp/vallora-back-log-registry.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
No projeto acima do serviço de log, você encontra todas as especificações de payloads para integração com suas rotinas no backend.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
* Version
|
|
9
|
-
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
|
|
7
|
+
### Como testar isoladamente ###
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
```bash
|
|
10
|
+
$ export GOOGLE_PROJECT_ID=omega-development-381223
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* Dependencies
|
|
16
|
-
* Database configuration
|
|
17
|
-
* How to run tests
|
|
18
|
-
* Deployment instructions
|
|
12
|
+
#Solicite a criação de um arquivo de service account do Google para o Admin
|
|
13
|
+
$ export GOOGLE_APPLICATION_CREDENTIALS="/Users/user-local/omega-development-381223-e6f174c57cbb.json"
|
|
19
14
|
|
|
20
|
-
|
|
15
|
+
$ mkdir sdk-local-test
|
|
16
|
+
$ cd sdk-local-test
|
|
17
|
+
$ npm install @omegasolutions/vallora-log-sdk
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
* Code review
|
|
24
|
-
* Other guidelines
|
|
19
|
+
```
|
|
25
20
|
|
|
26
|
-
|
|
21
|
+
Crie uma classe de teste index.js
|
|
27
22
|
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
import { LogClient, ServiceType } from '@omegasolutions/vallora-log-sdk';
|
|
24
|
+
|
|
25
|
+
const logClient = new LogClient();
|
|
26
|
+
|
|
27
|
+
await logClient.publishLog({
|
|
28
|
+
idMessage: 'bbb2f9c2-8a92-4bc8-bf93-23b2b05c4999',
|
|
29
|
+
idUser: 'a4a2f9c9-8a92-4bc8-bf93-23b2b05c49a1', //uuid
|
|
30
|
+
idService: ServiceType.SEND_TO_PAYMENT,
|
|
31
|
+
inputPayload: { orderId: 456, amount: 200.5 },
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
Finalmente, execute:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
$ node index.js
|
|
39
|
+
|
|
40
|
+
```
|
package/dist/log-client.js
CHANGED
|
@@ -5,7 +5,7 @@ const pubsub_1 = require("@google-cloud/pubsub");
|
|
|
5
5
|
const uuid_1 = require("uuid");
|
|
6
6
|
class LogClient {
|
|
7
7
|
constructor() {
|
|
8
|
-
this.topicName = 'transaction-log-topic';
|
|
8
|
+
this.topicName = process.env.TOPIC_LOGS_NAME || 'transaction-log-topic';
|
|
9
9
|
const projectId = process.env.GOOGLE_PROJECT_ID;
|
|
10
10
|
if (!projectId) {
|
|
11
11
|
throw new Error('Environment variable GOOGLE_PROJECT_ID is not defined. Please set it before using LogClient.');
|
package/package.json
CHANGED