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
space-infix-ops: 1
prefer-const: 0
curly: [error, multi-or-nest]
curly: [error, multi, consitent]
indent: [error, 4]
arrow-parens: [error, as-needed]
jasmine/no-focused-tests: 0

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
{
{
"db": {
"connector": "memory"
},
@ -7,77 +7,12 @@
"timezone": "CET",
"database": "vn",
"debug": false,
"host": "${salixHost}",
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"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}",
"host": "localhost",
"port": "3306",
"username": "root",
"password": "root",
"multipleStatements": true,
"connectTimeout": 20000,
"acquireTimeout": 20000
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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