@nclabs/nestjs-rpc-module
Advanced tools
Comparing version 0.2.10 to 0.2.11
@@ -55,3 +55,2 @@ "use strict"; | ||
ttl: parseInt(process.env.CACHE_TTL, 10) || 600, | ||
logCacheHit: process.env.CACHE_HIT_LOG === 'true', | ||
}, | ||
@@ -74,3 +73,4 @@ g5: { | ||
logResponse: process.env.LOG_RESPONSE === 'true', | ||
logErrorLevel: process.env.LOG_ERROR_LEVEL || 'info', | ||
logCacheOnly: process.env.LOG_CACHE_ONLY === 'true', | ||
logError: process.env.LOG_ERROR === 'true', | ||
retryAttempts: parseInt(process.env.LOGGER_RETRY_ATTEMPTS, 10), | ||
@@ -77,0 +77,0 @@ retrayDelay: parseInt(process.env.LOGGER_RETRY_DELAY, 10), |
@@ -20,3 +20,3 @@ "use strict"; | ||
Object.defineProperty(exports, "NclabsRpcModule", { enumerable: true, get: function () { return nclabs_rpc_module_1.NclabsRpcModule; } }); | ||
const nclabs_microservice_1 = require("./nclabs-microservice"); | ||
const nclabs_microservice_1 = require("./nclabs-microservice/nclabs-microservice"); | ||
Object.defineProperty(exports, "NclabsMicroservice", { enumerable: true, get: function () { return nclabs_microservice_1.NclabsMicroservice; } }); | ||
@@ -23,0 +23,0 @@ __exportStar(require("./common/decorators"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NclabsCacherService = exports.NclabsCacheInterceptor = void 0; | ||
exports.NclabsCacherService = void 0; | ||
const nclabs_cacher_service_1 = require("./nclabs-cacher.service"); | ||
Object.defineProperty(exports, "NclabsCacherService", { enumerable: true, get: function () { return nclabs_cacher_service_1.NclabsCacherService; } }); | ||
const nclabs_cacher_interceptor_1 = require("./nclabs-cacher.interceptor"); | ||
Object.defineProperty(exports, "NclabsCacheInterceptor", { enumerable: true, get: function () { return nclabs_cacher_interceptor_1.NclabsCacheInterceptor; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -8,3 +8,2 @@ "use strict"; | ||
}; | ||
var NclabsCacherModule_1; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -17,4 +16,4 @@ exports.NclabsCacherModule = void 0; | ||
const core_1 = require("@nestjs/core"); | ||
const nclabs_cacher_interceptor_1 = require("./nclabs-cacher.interceptor"); | ||
const nclabs_config_1 = require("../common/lib/nclabs-config"); | ||
const nclabs_cache_interceptor_service_1 = require("./nclabs-cache-interceptor.service"); | ||
/** | ||
@@ -45,34 +44,15 @@ * | ||
* | ||
* @returns RpcConfigModule | ||
* @returns NclabsCacherModule | ||
* | ||
*/ | ||
let NclabsCacherModule = NclabsCacherModule_1 = class NclabsCacherModule { | ||
static forRoot(autoInterceptCache = true) { | ||
// | ||
const providers = []; | ||
providers.push(core_1.Reflector); | ||
providers.push(nclabs_cacher_service_1.NclabsCacherService); | ||
const exports = []; | ||
exports.push(cache_manager_1.CacheModule); | ||
exports.push(nclabs_cacher_service_1.NclabsCacherService); | ||
if (autoInterceptCache) { | ||
providers.push({ | ||
provide: core_1.APP_INTERCEPTOR, | ||
useClass: nclabs_cacher_interceptor_1.NclabsCacheInterceptor, | ||
}); | ||
// exports.push(NclabsCacheInterceptor); | ||
} | ||
// Return | ||
return { | ||
module: NclabsCacherModule_1, | ||
imports: [cacheModule()], | ||
providers, | ||
exports, | ||
}; | ||
} | ||
let NclabsCacherModule = class NclabsCacherModule { | ||
}; | ||
exports.NclabsCacherModule = NclabsCacherModule; | ||
exports.NclabsCacherModule = NclabsCacherModule = NclabsCacherModule_1 = __decorate([ | ||
(0, common_1.Module)({}) | ||
exports.NclabsCacherModule = NclabsCacherModule = __decorate([ | ||
(0, common_1.Module)({ | ||
imports: [cacheModule()], | ||
providers: [core_1.Reflector, nclabs_cacher_service_1.NclabsCacherService, nclabs_cache_interceptor_service_1.NclabsCacheInterceptorService], | ||
exports: [cache_manager_1.CacheModule, nclabs_cacher_service_1.NclabsCacherService, nclabs_cache_interceptor_service_1.NclabsCacheInterceptorService], | ||
}) | ||
], NclabsCacherModule); | ||
//# sourceMappingURL=nclabs-cacher.module.js.map |
@@ -39,6 +39,6 @@ "use strict"; | ||
const key = `${this._prefixKey()}:${keyId}`; | ||
const CACHE_HIT_LOG = this.config.cache.logCacheHit; | ||
const LOG_CACHE_ONLY = this.config.logger.logCacheOnly; | ||
// | ||
const data = await this.cacheManager.get(key); | ||
if (data && CACHE_HIT_LOG) { | ||
if (data && LOG_CACHE_ONLY) { | ||
const logger = new common_1.Logger('CacherInterceptor'); | ||
@@ -59,4 +59,4 @@ logger.debug(`Return data from cache. Cache Key: ${key}`); | ||
const key = `${this._prefixKey()}:${keyId}`; | ||
const cacheTtl = this.config.cache.ttl; | ||
return this.cacheManager.set(key, value, { ttl: ttl || cacheTtl }); | ||
const cacheTtl = ttl === -1 ? 0 : ttl || this.config.cache.ttl; | ||
return this.cacheManager.set(key, value, { ttl: cacheTtl }); | ||
} | ||
@@ -63,0 +63,0 @@ /** |
@@ -14,7 +14,8 @@ "use strict"; | ||
const rpc_client_module_1 = require("./nclabs-client/rpc-client.module"); | ||
const nclabs_http_interceptor_1 = require("./nclabs-http.interceptor"); | ||
const core_1 = require("@nestjs/core"); | ||
const register_store_1 = require("./common/lib/register.store"); | ||
const nclabs_error_interceptor_1 = require("./nclabs-error.interceptor"); | ||
const nclabs_logger_interceptor_1 = require("./nclabs-logger.interceptor"); | ||
const nclabs_global_interceptor_1 = require("./nclabs-global.interceptor"); | ||
const nclabs_http_service_1 = require("./nclabs-http/nclabs-http.service"); | ||
const nclabs_error_service_1 = require("./nclabs-error/nclabs-error.service"); | ||
const nclabs_logger_service_1 = require("./nclabs-logger/nclabs-logger.service"); | ||
/** | ||
@@ -28,33 +29,23 @@ * | ||
const { autoInterceptCache = true } = options || {}; | ||
const importModules = []; | ||
importModules.push(nclabs_cacher_module_1.NclabsCacherModule.forRoot(autoInterceptCache)); | ||
importModules.push(rpc_client_module_1.NclabsClientModule); | ||
const exportModules = []; | ||
exportModules.push(nclabs_cacher_module_1.NclabsCacherModule); | ||
exportModules.push(rpc_client_module_1.NclabsClientModule); | ||
const providers = []; | ||
// LOGGER - It is mandatory use this interceptor before others | ||
providers.push({ | ||
provide: core_1.APP_INTERCEPTOR, | ||
useClass: nclabs_logger_interceptor_1.NclabsLoggerInterceptor, | ||
}); | ||
// HTTP | ||
providers.push({ | ||
provide: core_1.APP_INTERCEPTOR, | ||
useClass: nclabs_http_interceptor_1.NclabsHttpInterceptor, | ||
}); | ||
// ERROR | ||
providers.push({ | ||
provide: core_1.APP_INTERCEPTOR, | ||
useClass: nclabs_error_interceptor_1.NclabsErrorInterceptor, | ||
}); | ||
// Return | ||
return { | ||
module: NclabsRpcModule_1, | ||
imports: [...importModules], | ||
providers: [...providers], | ||
exports: [NclabsRpcModule_1, ...exportModules], | ||
imports: [nclabs_cacher_module_1.NclabsCacherModule, rpc_client_module_1.NclabsClientModule], | ||
providers: [ | ||
nclabs_http_service_1.NclabsHttpService, | ||
nclabs_error_service_1.NclabsErrorService, | ||
nclabs_logger_service_1.NclabsLoggerService, | ||
{ | ||
provide: core_1.APP_INTERCEPTOR, | ||
useClass: nclabs_global_interceptor_1.NclabsGlobalInterceptor, | ||
}, | ||
{ | ||
provide: 'AUTO_INTERCEPT_CACHE', | ||
useValue: autoInterceptCache, | ||
}, | ||
], | ||
exports: [NclabsRpcModule_1, nclabs_cacher_module_1.NclabsCacherModule, rpc_client_module_1.NclabsClientModule], | ||
}; | ||
} | ||
// After 30 seconds close register store | ||
// After 30 seconds close register store connection | ||
onApplicationBootstrap() { | ||
@@ -68,4 +59,6 @@ setTimeout(() => { | ||
exports.NclabsRpcModule = NclabsRpcModule = NclabsRpcModule_1 = __decorate([ | ||
(0, common_1.Module)({}) | ||
(0, common_1.Module)({ | ||
providers: [nclabs_http_service_1.NclabsHttpService], | ||
}) | ||
], NclabsRpcModule); | ||
//# sourceMappingURL=nclabs-rpc.module.js.map |
{ | ||
"name": "@nclabs/nestjs-rpc-module", | ||
"version": "0.2.10", | ||
"version": "0.2.11", | ||
"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", |
@@ -24,4 +24,4 @@ { | ||
"include": [ | ||
"src", | ||
"src", | ||
], | ||
} |
@@ -123,8 +123,2 @@ /** | ||
ttl: number; | ||
/** | ||
* Quando true, registra uma saída no console sempre que o dado for retornado do cache. | ||
* | ||
* @default false | ||
*/ | ||
logCacheHit: boolean; | ||
}; | ||
@@ -189,3 +183,4 @@ /** | ||
logResponse: boolean; | ||
logErrorLevel: string; | ||
logCacheOnly: boolean; | ||
logError: boolean; | ||
retryAttempts?: number; | ||
@@ -192,0 +187,0 @@ retrayDelay?: number; |
import { NclabsRpcModule } from './nclabs-rpc.module'; | ||
import { NclabsMicroservice } from './nclabs-microservice'; | ||
import { NclabsMicroservice } from './nclabs-microservice/nclabs-microservice'; | ||
export { NclabsRpcModule, NclabsMicroservice }; | ||
@@ -4,0 +4,0 @@ export * from './common/decorators'; |
import { NclabsCacherService } from './nclabs-cacher.service'; | ||
import { NclabsCacheInterceptor } from './nclabs-cacher.interceptor'; | ||
export { NclabsCacheInterceptor, NclabsCacherService }; | ||
export { NclabsCacherService }; |
@@ -1,9 +0,7 @@ | ||
import { DynamicModule } from '@nestjs/common'; | ||
/** | ||
* | ||
* @returns RpcConfigModule | ||
* @returns NclabsCacherModule | ||
* | ||
*/ | ||
export declare class NclabsCacherModule { | ||
static forRoot(autoInterceptCache?: boolean): DynamicModule; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances 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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
597270
170
4356