UNPKG

vulcain-corejs

Version:
99 lines (97 loc) 3.9 kB
"use strict"; const fs = require('fs'); const system_1 = require('./../configurations/globals/system'); /** * Conventions values * You can override this values before instanciating application * * @export * @class Conventions */ class Conventions { constructor() { /** * Default api source files * */ this.defaultApplicationFolder = "/api"; this.defaultModelsFolderPattern = "${base}/models"; this.defaultHandlersFolderPattern = "${base}/handlers"; this.defaultServicesFolderPattern = "${base}/services"; this.defaultHystrixPath = "/hystrix.stream"; this.defaultUrlprefix = "/api"; this.defaultRabbitAddress = "rabbit"; this.defaultMongoAddress = "mongo"; this.defaultStatsdAddress = "statsd-agent"; this.defaultStatsdDelayInMs = 10000; this.defaultVulcainServerName = "vulcain-server"; this.vulcainFileName = ".vulcain"; this.secretKeyPropertyName = "VulcainSecretKey"; this.defaultSecretKey = "DnQBnCG7*fjEX@Rw5uN^hWR4*AkRVKMeRu2#Ucu^ECUNWrKr"; this.defaultTokenExpiration = "20m"; /** * Environment variable for rabbit server address * */ this.ENV_TOKEN_ISSUER = "VULCAIN_TOKEN_ISSUER"; this.ENV_TOKEN_EXPIRATION = "VULCAIN_TOKEN_EXPIRATION"; this.ENV_VULCAIN_TENANT = "VULCAIN_TENANT"; /** * Api key to get config from vulcain server * * * @memberOf Conventions */ this.ENV_VULCAIN_TOKEN = "VULCAIN_TOKEN"; this.ENV_VULCAIN_ENV = "VULCAIN_ENV"; this.ENV_VULCAIN_DOMAIN = "VULCAIN_DOMAIN"; this.ENV_VULCAIN_SERVER = "VULCAIN_SERVER"; this.ENV_SERVICE_NAME = "VULCAIN_SERVICE_NAME"; this.ENV_SERVICE_VERSION = "VULCAIN_SERVICE_VERSION"; this.ENV_VULCAIN_TEST = "VULCAIN_TEST"; this.ENV_VULCAIN_SECRET_KEY = "VULCAIN_SECRET_KEY"; this.hystrix = { "hystrix.health.snapshot.validityInMilliseconds": 500, "hystrix.force.circuit.open": false, "hystrix.force.circuit.closed": false, "hystrix.circuit.enabled": true, "hystrix.circuit.sleepWindowInMilliseconds": 5000, "hystrix.circuit.errorThresholdPercentage": 50, "hystrix.circuit.volumeThreshold": 10, "hystrix.execution.timeoutInMilliseconds": 1500, "hystrix.metrics.statistical.window.timeInMilliseconds": 10000, "hystrix.metrics.statistical.window.bucketsNumber": 10, "hystrix.metrics.percentile.window.timeInMilliseconds": 10000, "hystrix.metrics.percentile.window.bucketsNumber": 10, "hystrix.isolation.semaphore.maxConcurrentRequests": 10, "hystrix.fallback.semaphore.maxConcurrentRequests": 10 }; } static deepAssign(from, target) { from && Object.keys(from).forEach(k => { if (typeof from === "Object") { target[k] = target[k] || {}; Conventions.deepAssign(from[k], target[k]); } else target[k] = from[k]; }); } static get instance() { if (!Conventions._instance) { Conventions._instance = new Conventions(); try { if (fs.existsSync("vulcain.conventions")) { const data = JSON.parse(fs.readFileSync("vulcain.conventions", "utf8")); Conventions.deepAssign(data, Conventions._instance); } } catch (e) { system_1.System.log.error(null, e, "Error when reading vulcain.conventions file. Custom conventions are ignored."); } } return Conventions._instance; } } exports.Conventions = Conventions; //# sourceMappingURL=conventions.js.map