feat: remove path alias.

feat: remove Webpack and depend on nodemon.
feat: refactoring expenses.
feat: optimize system users with caching.
feat: architecture tenant optimize.
This commit is contained in:
Ahmed Bouhuolia
2020-09-15 00:51:39 +02:00
parent ad00f140d1
commit a22c8395f3
293 changed files with 3391 additions and 1637 deletions

100
server/src/config/index.js Normal file
View File

@@ -0,0 +1,100 @@
import dotenv from 'dotenv';
// Set the NODE_ENV to 'development' by default
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
const envFound = dotenv.config();
if (envFound.error) {
// This error should crash whole process
throw new Error("⚠️ Couldn't find .env file ⚠️");
}
export default {
/**
* Your favorite port
*/
port: parseInt(process.env.PORT, 10),
system: {
db_client: 'mysql',
db_host: '127.0.0.1',
db_user: 'root',
db_password: 'root',
db_name: 'bigcapital_system',
migrations_dir: './src/system/migrations',
seeds_dir: './src/system/seeds',
},
tenant: {
db_client: 'mysql',
db_name_prefix: 'bigcapital_tenant_',
db_host: '127.0.0.1',
db_user: 'root',
db_password: 'root',
charset: 'utf8',
migrations_dir: 'src/database/migrations',
seeds_dir: 'src/database/seeds/core',
seeds_table_name: 'seeds_versioning',
},
manager: {
superUser: 'root',
superPassword: 'root',
},
mail: {
host: 'smtp.mailtrap.io',
port: 587,
secure: false,
username: '842f331d3dc005',
password: '172f97b34f1a17',
},
mongoDb: {
/**
* That long string from mlab
*/
databaseURL: 'mongodb://localhost/bigcapital',
},
/**
* Agenda.js stuff
*/
agenda: {
dbCollection: process.env.AGENDA_DB_COLLECTION,
pooltime: process.env.AGENDA_POOL_TIME,
concurrency: parseInt(process.env.AGENDA_CONCURRENCY, 10),
},
/**
* Agendash config
*/
agendash: {
user: 'agendash',
password: '123456'
},
/**
* Subscription config.
*/
subscription: {
user: 'root',
password: 'root',
},
SMSGateway: {
type: '',
endpoint: '',
},
easySMSGateway: {
api_key: 'b0JDZW56RnV6aEthb0RGPXVEcUI'
},
jwtSecret: 'b0JDZW56RnV6aEthb0RGPXVEcUI',
contactUsMail: 'support@bigcapital.ly',
baseURL: 'https://bigcapital.ly',
api: {
prefix: '/api'
},
resetPasswordSeconds: 600,
licensesAuth: {
user: 'admin',
password: 'admin',
},
};

View File

@@ -0,0 +1,58 @@
import config from 'config';
import { ITenant } from 'interfaces';
export const tenantKnexConfig = (tenant: ITenant) => {
const { organizationId, id } = tenant;
return {
client: config.tenant.db_client,
connection: {
host: config.tenant.db_host,
user: config.tenant.db_user,
password: config.tenant.db_password,
database: `${config.tenant.db_name_prefix}${organizationId}`,
charset: config.tenant.charset,
},
migrations: {
directory: config.tenant.migrations_dir,
},
seeds: {
directory: config.tenant.seeds_dir,
},
pool: { min: 0, max: 5 },
userParams: {
tenantId: id,
organizationId
}
};
};
export const systemKnexConfig = {
client: config.system.db_client,
connection: {
host: config.system.db_host,
user: config.system.db_user,
password: config.system.db_password,
database: config.system.db_name,
charset: 'utf8',
},
migrations: {
directory: config.system.migrations_dir,
},
seeds: {
directory: config.system.seeds_dir,
},
pool: { min: 0, max: 7 },
};
export const systemDbManager = {
collate: [],
superUser: config.manager.superUser,
superPassword: config.manager.superPassword,
};
export const tenantSeedConfig = (tenant: ITenant) => {
return {
directory: config.tenant.seeds_dir,
};
}