@nclabs/nestjs-rpc-module
Advanced tools
Comparing version 0.1.41 to 0.1.42
```bash | ||
# ######################################################################### # | ||
# SERVICES DESCRIPTOR # | ||
# SERVICES REGISTER # | ||
# ######################################################################### # | ||
@@ -16,3 +15,3 @@ REGISTER_PREFIX=API-REGISTER | ||
API_PREFIX=api | ||
API_PORT=3000 | ||
API_PORT=3100 | ||
@@ -23,3 +22,3 @@ | ||
# ######################################################################### # | ||
NATS_HOST=localhost | ||
NATS_HOST=172.17.0.1 | ||
NATS_PORT=4222 | ||
@@ -31,5 +30,6 @@ | ||
# ######################################################################### # | ||
REDIS_HOST=localhost | ||
REDIS_HOST=172.17.0.1 | ||
REDIS_PORT=6379 | ||
REDIS_PASSWORD=ucbGPPyF5cwAmQmGjyA7Nsy52oy1ImF | ||
REDIS_PASSWORD=oy1ImFucbGPPmQmGjyA7yF5cwANsy52 | ||
REDIS_DB=0 | ||
@@ -47,3 +47,2 @@ # ------------------------------------------------------------------------- | ||
# ######################################################################### # | ||
@@ -55,8 +54,7 @@ # CACHE # | ||
CACHE_HIT_LOG=true | ||
CACHE_DB=0 | ||
# ######################################################################### # | ||
# SENIOR # | ||
# ######################################################################### # | ||
# G5_BASE_URL=https://<server>:<port>/g5-senior-services/ | ||
G5_BASE_URL=http://192.168.1.202:8081/g5-senior-services/ | ||
@@ -75,3 +73,2 @@ G5_CRYPT_KEY=123456 | ||
# ######################################################################### # | ||
@@ -83,7 +80,13 @@ # LOGGER HUB # | ||
# Tentativas de envio para o Logger HUB - Default 10 | ||
LOGGER_RETRY_ATTEMPTS=10 | ||
# Tempo de espera (exponencial) entre as tentativa - Default 4000 | ||
LOGGER_RETRY_DELAY=4000 | ||
# Gerar log de repostas com sucesso | ||
LOG_RESPONSE=false | ||
# Nível de log dos erros | ||
LOG_ERROR_LEVEL=error | ||
# # Tentativas de envio para o Logger HUB - Default 10 | ||
# LOGGER_RETRY_ATTEMPTS=10 | ||
# # Tempo de espera (exponencial) entre as tentativa - Default 4000 | ||
# LOGGER_RETRY_DELAY=4000 | ||
``` |
{ | ||
"name": "@nclabs/nestjs-rpc-module", | ||
"version": "0.1.41", | ||
"version": "0.1.42", | ||
"description": "Utilitário NestJS para configuração de rotas e cache em microsserviços. Utilizado especificamente para projetos nclabs", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -31,7 +31,7 @@ # nestjs-nclabs-rpc-module | ||
> Arquivo de configuração modelo: https://github.com/nclabs-npm/nestjs-nclabs-rpc-module/blob/main/config.md | ||
> Arquivo de configuração modelo: https://github.com/nclabs-npm/nestjs-nc-template/blob/main/dist/docker-compose.env | ||
<br /> | ||
Variável de ambiente que deve ser setada no docker-compose.yml: | ||
Variável de ambiente que __DEVE__ ser setada no docker-compose.yml: | ||
@@ -45,4 +45,18 @@ ```bash | ||
Variáveis de ambiente que PODEM ser setada no docker-compose.yml: | ||
```bash | ||
environment: | ||
... | ||
# Gerar log de repostas com sucesso | ||
LOG_RESPONSE=<true | false> | ||
# Nível de log dos erros | ||
LOG_ERROR_LEVEL=<debug | info | warn | error | fatal> | ||
``` | ||
<br /> | ||
@@ -89,4 +103,2 @@ <br /> | ||
| **NclabsCacherService** | Provider | Controller Service | Métodos para o tratamento manual do cache | | ||
| [**NclabsRxjsErrorHandler**](#exceptions) | Lib | Observable Approach | Trata exceções do microserviço (catchError) | | ||
| [**NclabsException**](#exceptions) | Lib | Promise Approach | Trata exceções do microserviço | | ||
| [**INclabsException**](#exceptions) | Interface | * | Tipo de exceção do microserviço | | ||
@@ -350,2 +362,7 @@ | ||
AS requisições REST e chamadas de serviço (`...client.call`) abstraem a normalização do objeto de exceções. | ||
Quando for necessário lançar exceções manualmente, utilizar a sintaxe abaixo: | ||
```typescript | ||
@@ -363,38 +380,4 @@ // app.controller.ts | ||
/** | ||
* | ||
* | ||
*/ | ||
youMethod(token: string, includeG5 = false): Observable<IUser> { | ||
const url = `${baseUrl}platform/user/queries/getUser`; | ||
const headers = { | ||
Authorization: `Bearer ${token}`, | ||
}; | ||
return this.httpService.get<IUser>(url, { headers }).pipe( | ||
// get data | ||
map((response: AxiosResponse<IUser>) => response.data), | ||
// append authentication | ||
map((data: IUser) => ({ ...data, authentication: `Bearer ${token}` })), | ||
// map response to IUser | ||
map(this._mapResponseToIUser), | ||
// generate password for G5 | ||
map((user: IUser) => { | ||
if (includeG5) { | ||
const password = this._generateEncryptPassword(user.username); | ||
user.password = password; | ||
user.encryption = 2; | ||
} | ||
return user; | ||
}), | ||
catchError(NclabsRxjsErrorHandler), | ||
); | ||
} | ||
/** | ||
* | ||
* Generate password for G5 | ||
@@ -419,3 +402,4 @@ * | ||
}; | ||
throw new NclabsException(error); | ||
throw new RpcException(error); | ||
} | ||
@@ -422,0 +406,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
438539
411