inceptum
Advanced tools
Comparing version 0.8.9 to 0.8.10
@@ -28,2 +28,3 @@ export { JsonProvider } from './config/JsonProvider'; | ||
export * from './ioc/Decorators'; | ||
export { WebDecorator } from './web/WebDecorators'; | ||
export { NewrelicUtil } from './newrelic/NewrelicUtil'; | ||
@@ -30,0 +31,0 @@ export { RabbitmqConsumerHandler, Message } from './rabbitmq/RabbitmqConsumerHandler'; |
@@ -59,2 +59,4 @@ "use strict"; | ||
__export(require("./ioc/Decorators")); | ||
var WebDecorators_1 = require("./web/WebDecorators"); | ||
exports.WebDecorator = WebDecorators_1.WebDecorator; | ||
var NewrelicUtil_1 = require("./newrelic/NewrelicUtil"); | ||
@@ -61,0 +63,0 @@ exports.NewrelicUtil = NewrelicUtil_1.NewrelicUtil; |
@@ -21,2 +21,6 @@ "use strict"; | ||
Object.keys(confs).forEach((key) => { | ||
if (Object.hasOwnProperty.call(confs[key], 'enabled') && (confs[key].enabled === false || confs[key].enabled === 'false')) { | ||
// Skip this definition as it has been specifically disabled | ||
return; | ||
} | ||
const clientSingleton = new BaseSingletonDefinition_1.BaseSingletonDefinition(MySQLClient_1.MySQLClient, key); | ||
@@ -26,12 +30,16 @@ const config = Object.assign({}, confs[key], { name: key }); | ||
context.registerSingletons(clientSingleton); | ||
const masterHealthCheck = new BaseSingletonDefinition_1.BaseSingletonDefinition(MySQLHealthCheck_1.MySQLHealthCheck, `HC_${key}_master`); | ||
masterHealthCheck.constructorParamByValue(`mysql.${key}.master`); | ||
masterHealthCheck.constructorParamByValue(false); | ||
masterHealthCheck.setPropertyByRef('mysqlClient', key); | ||
context.registerDefinition(masterHealthCheck); | ||
const slaveHealthCheck = new BaseSingletonDefinition_1.BaseSingletonDefinition(MySQLHealthCheck_1.MySQLHealthCheck, `HC_${key}_slave`); | ||
slaveHealthCheck.constructorParamByValue(`mysql.${key}.slave`); | ||
slaveHealthCheck.constructorParamByValue(true); | ||
slaveHealthCheck.setPropertyByRef('mysqlClient', key); | ||
context.registerDefinition(slaveHealthCheck); | ||
if (confs[key].master) { | ||
const masterHealthCheck = new BaseSingletonDefinition_1.BaseSingletonDefinition(MySQLHealthCheck_1.MySQLHealthCheck, `HC_${key}_master`); | ||
masterHealthCheck.constructorParamByValue(`mysql.${key}.master`); | ||
masterHealthCheck.constructorParamByValue(false); | ||
masterHealthCheck.setPropertyByRef('mysqlClient', key); | ||
context.registerDefinition(masterHealthCheck); | ||
} | ||
if (confs[key].slave) { | ||
const slaveHealthCheck = new BaseSingletonDefinition_1.BaseSingletonDefinition(MySQLHealthCheck_1.MySQLHealthCheck, `HC_${key}_slave`); | ||
slaveHealthCheck.constructorParamByValue(`mysql.${key}.slave`); | ||
slaveHealthCheck.constructorParamByValue(true); | ||
slaveHealthCheck.setPropertyByRef('mysqlClient', key); | ||
context.registerDefinition(slaveHealthCheck); | ||
} | ||
}); | ||
@@ -38,0 +46,0 @@ } |
@@ -14,2 +14,3 @@ import { BaseSingletonDefinition } from '../ioc/objectdefinition/BaseSingletonDefinition'; | ||
doInspect(objectDefinition: SingletonDefinition<any>): void; | ||
private processRoutes(routes, objectDefinition); | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const BaseSingletonDefinition_1 = require("../ioc/objectdefinition/BaseSingletonDefinition"); | ||
const AbstractObjectDefinitionInspector_1 = require("../ioc/AbstractObjectDefinitionInspector"); | ||
const SingletonDefinition_1 = require("../ioc/objectdefinition/SingletonDefinition"); | ||
const WebDecorators_1 = require("./WebDecorators"); | ||
class WebRoutingInspector extends AbstractObjectDefinitionInspector_1.AbstractObjectDefinitionInspector { | ||
@@ -14,4 +15,7 @@ constructor(definition) { | ||
interestedIn(objectDefinition) { | ||
return (objectDefinition instanceof SingletonDefinition_1.SingletonDefinition) | ||
&& (objectDefinition.getProducedClass().routes !== undefined); | ||
if (!(objectDefinition instanceof BaseSingletonDefinition_1.BaseSingletonDefinition)) { | ||
return false; | ||
} | ||
return (objectDefinition.getProducedClass().routes !== undefined) || | ||
WebDecorators_1.hasWebDecoratorMetadata(objectDefinition.getProducedClass().prototype); | ||
} | ||
@@ -23,3 +27,12 @@ /** | ||
doInspect(objectDefinition) { | ||
const routes = objectDefinition.getProducedClass().routes; | ||
if (objectDefinition.getProducedClass().routes) { | ||
// Old way | ||
this.processRoutes(objectDefinition.getProducedClass().routes || [], objectDefinition); | ||
} | ||
if (WebDecorators_1.hasWebDecoratorMetadata(objectDefinition.getProducedClass().prototype)) { | ||
// New way | ||
this.processRoutes(WebDecorators_1.getWebDecoratorMetadata(objectDefinition.getProducedClass().prototype).routes || [], objectDefinition); | ||
} | ||
} | ||
processRoutes(routes, objectDefinition) { | ||
routes.forEach((route, index) => { | ||
@@ -26,0 +39,0 @@ const instanceName = `instance_${index}`; |
{ | ||
"name": "inceptum", | ||
"version": "0.8.9", | ||
"version": "0.8.10", | ||
"description": "hipages take on the foundational library for enterprise-grade apps written in NodeJS", | ||
@@ -18,9 +18,11 @@ "main": "dist/index.js", | ||
"postpublish": "npm run deploy-docs", | ||
"prepublishOnly": "npm run clean && tsc && npm test && npm run lint", | ||
"prepublishOnly": "npm run clean && tsc && npm run lint && npm test", | ||
"precommit": "npm run lint", | ||
"prepush": "node .checkpush.js" | ||
"prepush": "node .checkpush.js", | ||
"release": "yarn prepublishOnly && semantic-release", | ||
"semantic-release": "semantic-release" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/hipages/inceptum.git" | ||
"url": "https://github.com/hipages/inceptum.git" | ||
}, | ||
@@ -103,2 +105,3 @@ "engine": { | ||
"nyc": "^11.1.0", | ||
"semantic-release": "^15.1.7", | ||
"sinon": "1.17.7", | ||
@@ -105,0 +108,0 @@ "ts-mockito": "^2.2.7", |
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
449355
224
6813
23