Unified datasources

This commit is contained in:
Juan Ferrer 2018-12-17 11:28:39 +01:00
parent ed8ac4652e
commit 50bebbba36
48 changed files with 97 additions and 179 deletions

View File

@ -26,7 +26,7 @@ rules:
bracketSpacing: 0 bracketSpacing: 0
space-infix-ops: 1 space-infix-ops: 1
prefer-const: 0 prefer-const: 0
curly: [error, multi-or-nest] curly: [error, multi, consitent]
indent: [error, 4] indent: [error, 4]
arrow-parens: [error, as-needed] arrow-parens: [error, as-needed]
jasmine/no-focused-tests: 0 jasmine/no-focused-tests: 0

View File

@ -6,5 +6,4 @@ services:
context: ./services/nginx context: ./services/nginx
ports: ports:
- 80:80 - 80:80
- 443:443
links: [] links: []

View File

@ -6,7 +6,6 @@ const exec = require('child_process').exec;
const PluginError = require('plugin-error'); const PluginError = require('plugin-error');
const argv = require('minimist')(process.argv.slice(2)); const argv = require('minimist')(process.argv.slice(2));
const log = require('fancy-log'); const log = require('fancy-log');
const environment = require('gulp-env');
// Configuration // Configuration
@ -41,12 +40,6 @@ gulp.task('default', () => {
return gulp.start('services', 'client'); return gulp.start('services', 'client');
}); });
gulp.task('environment', async () => {
await environment({
file: '.env.json'
});
});
gulp.task('client', ['build-clean'], async () => { gulp.task('client', ['build-clean'], async () => {
await runSequenceP(['routes', 'locales'], 'watch', 'webpack-dev-server'); await runSequenceP(['routes', 'locales'], 'watch', 'webpack-dev-server');
}); });
@ -61,7 +54,7 @@ gulp.task('services', async () => {
/** /**
* Starts backend services. * Starts backend services.
*/ */
gulp.task('services-only', ['environment'], async () => { gulp.task('services-only', async () => {
const services = await getServices(); const services = await getServices();
for (let service of services) for (let service of services)
require(service.index).start(service.port); require(service.index).start(service.port);
@ -147,7 +140,7 @@ gulp.task('install', () => {
// Deployment // Deployment
gulp.task('build', ['clean'], async () => { gulp.task('build', ['clean'], async () => {
await runSequenceP(['environment', 'routes', 'locales', 'webpack', 'docker-compose', 'nginx-conf']); await runSequenceP(['routes', 'locales', 'webpack', 'docker-compose', 'nginx-conf']);
}); });
gulp.task('docker-compose', async () => { gulp.task('docker-compose', async () => {
@ -179,11 +172,7 @@ gulp.task('docker-compose', async () => {
}, },
ports: [`${service.port}:${defaultPort}`], ports: [`${service.port}:${defaultPort}`],
environment: { environment: {
NODE_ENV: '${NODE_ENV}', NODE_ENV: '${NODE_ENV}'
salixHost: '${salixHost}',
salixPort: '${salixPort}',
salixUser: '${salixUser}',
salixPassword: '${salixPassword}'
} }
}; };
@ -200,9 +189,6 @@ gulp.task('docker-compose', async () => {
restart: 'unless-stopped', restart: 'unless-stopped',
volumes: ['/config:/config'] volumes: ['/config:/config']
}); });
service.build.labels = {
'salix.tag': imageTag
};
} }
let ymlString = yaml.safeDump(composeYml); let ymlString = yaml.safeDump(composeYml);

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "claimDevelopment", "table": "claimDevelopment"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "claimEnd", "table": "claimEnd"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "claimReason", "table": "claimReason"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "claimRedelivery", "table": "claimRedelivery"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "claimResponsible", "table": "claimResponsible"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "claimResult", "table": "claimResult"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "claimState", "table": "claimState"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "addressObservation", "table": "addressObservation"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "bankEntity", "table": "bankEntity"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -9,8 +9,7 @@
}, },
"options": { "options": {
"mysql": { "mysql": {
"table": "clientContact", "table": "clientContact"
"database": "vn"
} }
}, },
"validateUpsert": true, "validateUpsert": true,

View File

@ -4,8 +4,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "clientCredit", "table": "clientCredit"
"database": "vn"
} }
}, },
"validateUpsert": true, "validateUpsert": true,

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "clientRisk", "table": "clientRisk"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -4,8 +4,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "defaulter", "table": "defaulter"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "observationType", "table": "observationType"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "tpvError", "table": "hedera.tpvError"
"database": "hedera"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "tpvMerchant", "table": "hedera.tpvMerchant"
"database": "hedera"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "tpvResponse", "table": "hedera.tpvResponse"
"database": "hedera"
} }
}, },
"properties": { "properties": {

View File

@ -48,13 +48,13 @@
"dataSource": "vn" "dataSource": "vn"
}, },
"TpvError": { "TpvError": {
"dataSource": "hedera" "dataSource": "vn"
}, },
"TpvMerchant": { "TpvMerchant": {
"dataSource": "hedera" "dataSource": "vn"
}, },
"TpvResponse": { "TpvResponse": {
"dataSource": "hedera" "dataSource": "vn"
}, },
"Defaulter": { "Defaulter": {
"dataSource": "vn" "dataSource": "vn"

View File

@ -3,7 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "genus" "table": "edi.genus"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "itemBarcode", "table": "itemBarcode"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "itemLog", "table": "itemLog"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "itemPlacement", "table": "itemPlacement"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,9 +3,8 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "itemTypeTag", "table": "itemTypeTag"
"database": "vn" }
}
}, },
"properties": { "properties": {
"id": { "id": {

View File

@ -3,7 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "specie" "table": "edi.specie"
} }
}, },
"properties": { "properties": {

View File

@ -18,10 +18,10 @@
"dataSource": "vn" "dataSource": "vn"
}, },
"Specie": { "Specie": {
"dataSource": "edi" "dataSource": "vn"
}, },
"Genus": { "Genus": {
"dataSource": "edi" "dataSource": "vn"
}, },
"ItemTypeTag": { "ItemTypeTag": {
"dataSource": "vn" "dataSource": "vn"

View File

@ -3,7 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "user" "table": "account.user"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "claimBeginning", "table": "claimBeginning"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "claimDestination", "table": "claimDestination"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "claimRatio", "table": "claimRatio"
"database": "vn"
} }
}, },
"validateUpsert": true, "validateUpsert": true,

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "claim", "table": "claim"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,7 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "fieldAcl" "table": "salix.fieldAcl"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "itemTag", "table": "itemTag"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,7 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "order" "table": "hedera.order"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "tag", "table": "tag"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "ticketObservation", "table": "ticketObservation"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "ticketTracking", "table": "ticketTracking"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "userConfig", "table": "userConfig"
"database": "vn"
} }
}, },
"properties": { "properties": {

View File

@ -1,6 +1,11 @@
{ {
"name": "user", "name": "user",
"base": "User", "base": "User",
"options": {
"mysql": {
"table": "salix.user"
}
},
"properties": { "properties": {
"id": { "id": {
"id": true, "id": true,

View File

@ -3,7 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "workerMana" "table": "bs.workerMana"
} }
}, },
"properties": { "properties": {

View File

@ -1,4 +1,4 @@
{ {
"db": { "db": {
"connector": "memory" "connector": "memory"
}, },
@ -7,77 +7,12 @@
"timezone": "CET", "timezone": "CET",
"database": "vn", "database": "vn",
"debug": false, "debug": false,
"host": "${salixHost}", "host": "localhost",
"port": "${salixPort}", "port": "3306",
"username": "${salixUser}", "username": "root",
"password": "${salixPassword}", "password": "root",
"multipleStatements": true,
"connectTimeout": 20000,
"acquireTimeout": 20000
},
"salix": {
"connector": "vn-mysql",
"timezone": "CET",
"database": "salix",
"debug": false,
"host": "${salixHost}",
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"multipleStatements": true,
"connectTimeout": 20000,
"acquireTimeout": 20000
},
"account": {
"connector": "vn-mysql",
"timezone": "CET",
"database": "account",
"debug": false,
"host": "${salixHost}",
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"multipleStatements": true,
"connectTimeout": 20000,
"acquireTimeout": 20000
},
"edi": {
"connector": "vn-mysql",
"timezone": "CET",
"database": "edi",
"debug": false,
"host": "${salixHost}",
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"multipleStatements": true,
"connectTimeout": 20000,
"acquireTimeout": 20000
},
"bs": {
"connector": "vn-mysql",
"timezone": "CET",
"database": "bs",
"debug": false,
"host": "${salixHost}",
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"multipleStatements": true,
"connectTimeout": 20000,
"acquireTimeout": 20000
},
"hedera": {
"connector": "vn-mysql",
"timezone": "CET",
"database": "hedera",
"debug": false,
"host": "${salixHost}",
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"multipleStatements": true, "multipleStatements": true,
"connectTimeout": 20000, "connectTimeout": 20000,
"acquireTimeout": 20000 "acquireTimeout": 20000
} }
} }

View File

@ -1,9 +1,14 @@
{ {
"user": { "user": {
"dataSource": "salix" "dataSource": "vn"
}, },
"AccessToken": { "AccessToken": {
"dataSource": "salix", "dataSource": "vn",
"options": {
"mysql": {
"table": "salix.AccessToken"
}
},
"relations": { "relations": {
"user": { "user": {
"type": "belongsTo", "type": "belongsTo",
@ -13,7 +18,12 @@
} }
}, },
"ACL": { "ACL": {
"dataSource": "salix" "dataSource": "vn",
"options": {
"mysql": {
"table": "salix.ACL"
}
}
}, },
"Claim": { "Claim": {
"dataSource": "vn" "dataSource": "vn"
@ -22,7 +32,7 @@
"dataSource": "vn" "dataSource": "vn"
}, },
"FieldAcl": { "FieldAcl": {
"dataSource": "salix" "dataSource": "vn"
}, },
"ObservationType": { "ObservationType": {
"dataSource": "vn" "dataSource": "vn"
@ -34,13 +44,23 @@
"dataSource": "vn" "dataSource": "vn"
}, },
"RoleMapping": { "RoleMapping": {
"dataSource": "salix" "dataSource": "vn",
"options": {
"mysql": {
"table": "salix.RoleMapping"
}
}
}, },
"Role": { "Role": {
"dataSource": "salix" "dataSource": "vn",
"options": {
"mysql": {
"table": "salix.Role"
}
}
}, },
"Account": { "Account": {
"dataSource": "account" "dataSource": "vn"
}, },
"Address": { "Address": {
"dataSource": "vn" "dataSource": "vn"
@ -151,7 +171,7 @@
"dataSource": "vn" "dataSource": "vn"
}, },
"WorkerMana": { "WorkerMana": {
"dataSource": "bs" "dataSource": "vn"
}, },
"DeliveryMethod": { "DeliveryMethod": {
"dataSource": "vn" "dataSource": "vn"
@ -178,6 +198,6 @@
"dataSource": "vn" "dataSource": "vn"
}, },
"Order": { "Order": {
"dataSource": "hedera" "dataSource": "vn"
} }
} }

View File

@ -11,11 +11,12 @@ let _resolveConnector = DataSource._resolveConnector;
DataSource._resolveConnector = function(name) { DataSource._resolveConnector = function(name) {
let testPath = `${__dirname}/connectors/${name}.js`; let testPath = `${__dirname}/connectors/${name}.js`;
if (fs.existsSync(testPath)) if (fs.existsSync(testPath)) {
return { return {
connector: require(testPath), connector: require(testPath),
error: null error: null
}; };
}
return _resolveConnector.apply(this, arguments); return _resolveConnector.apply(this, arguments);
}; };
@ -104,9 +105,8 @@ function vnBoot(app, rootDir, rootModule) {
let config = require('./config.json'); let config = require('./config.json');
for (let key in config) { for (let key in config)
app.set(key, config[key]); app.set(key, config[key]);
}
let modelConfigFiles = [ let modelConfigFiles = [
`${__dirname}/model-config.json`, `${__dirname}/model-config.json`,
@ -115,9 +115,10 @@ function vnBoot(app, rootDir, rootModule) {
let modelConfig = {}; let modelConfig = {};
for (file of modelConfigFiles) for (file of modelConfigFiles) {
if (fs.existsSync(file)) if (fs.existsSync(file))
Object.assign(modelConfig, require(file)); Object.assign(modelConfig, require(file));
}
let bootOptions = { let bootOptions = {
appRootDir: __dirname, appRootDir: __dirname,
@ -142,6 +143,9 @@ function vnBoot(app, rootDir, rootModule) {
] ]
}; };
if (fs.existsSync(`/config`))
bootOptions.dsRootDir = `/config`;
boot(app, bootOptions, function(err) { boot(app, bootOptions, function(err) {
if (err) throw err; if (err) throw err;
if (require.main === rootModule) if (require.main === rootModule)

View File

@ -3,7 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "orderRow" "table": "hedera.orderRow"
} }
}, },
"properties": { "properties": {

View File

@ -1,5 +1,5 @@
{ {
"OrderRow": { "OrderRow": {
"dataSource": "hedera" "dataSource": "vn"
} }
} }

View File

@ -3,8 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "saleTracking", "table": "saleTracking"
"database": "vn"
} }
}, },
"properties": { "properties": {