all basic config done
This commit is contained in:
+4
-2
@@ -55,8 +55,10 @@ typings/
|
|||||||
.yarn-integrity
|
.yarn-integrity
|
||||||
|
|
||||||
# dotenv environment variables file
|
# dotenv environment variables file
|
||||||
.env
|
# local .env* files
|
||||||
.env.test
|
.env*
|
||||||
|
.env.local
|
||||||
|
.env.*.local
|
||||||
|
|
||||||
# parcel-bundler cache (https://parceljs.org/)
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
.cache
|
.cache
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
require('dotenv/config');
|
require('dotenv/config');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
local: {
|
development: {
|
||||||
username: 'root',
|
username: 'root',
|
||||||
password: 'water',
|
password: 'water',
|
||||||
database: 'ucharify',
|
database: 'ucharify',
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
dialect: 'mysql'
|
dialect: 'mysql'
|
||||||
},
|
},
|
||||||
staging: {
|
test: {
|
||||||
username: 'root',
|
username: 'root',
|
||||||
password: null,
|
password: null,
|
||||||
database: 'database_test',
|
database: 'database_test',
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const Sequelize = require('sequelize'),
|
|||||||
UserModel = require('../models/user.model.js'),
|
UserModel = require('../models/user.model.js'),
|
||||||
PaymentPlanModel = require('../models/paymentplan.model'),
|
PaymentPlanModel = require('../models/paymentplan.model'),
|
||||||
ChargeModel = require('../models/charge.model');
|
ChargeModel = require('../models/charge.model');
|
||||||
associate = require('./associate');
|
associate = require('./associate');
|
||||||
|
|
||||||
const connection_uri = process.env.JAWSDB_MARIA_URL;
|
const connection_uri = process.env.JAWSDB_MARIA_URL;
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -1,2 +1,6 @@
|
|||||||
require('dotenv/config');
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
||||||
|
|
||||||
|
require('dotenv-flow').config({
|
||||||
|
node_env: process.env.NODE_ENV
|
||||||
|
});
|
||||||
require('../server');
|
require('../server');
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
process.env.NODE_ENV = process.env.NODE_ENV || 'test';
|
||||||
|
|
||||||
|
require('dotenv-flow').config({
|
||||||
|
node_env: process.env.NODE_ENV
|
||||||
|
});
|
||||||
|
require('../server');
|
||||||
Generated
+9
@@ -131,6 +131,15 @@
|
|||||||
"integrity": "sha512-HygQCKUBSFl8wKQZBSemMywRWcEDNidvNbjGVyZu3nbZ8qq9ubiPoGLMdRDpfSrpkkm9BXYFkpKxxFX38o/76w==",
|
"integrity": "sha512-HygQCKUBSFl8wKQZBSemMywRWcEDNidvNbjGVyZu3nbZ8qq9ubiPoGLMdRDpfSrpkkm9BXYFkpKxxFX38o/76w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"dotenv-flow": {
|
||||||
|
"version": "0.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/dotenv-flow/-/dotenv-flow-0.2.0.tgz",
|
||||||
|
"integrity": "sha512-Lmw/iJmgvMMZ/TStj+RrsT38WlaFy+5y6jwmHKoCh4MJp8U2etajnXMjhcIdBYKEkjqXzle4UbRVLhFx0t5YKg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"dotenv": "^6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"dottie": {
|
"dottie": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.1.tgz",
|
||||||
|
|||||||
+7
-4
@@ -4,10 +4,13 @@
|
|||||||
"description": "Backend API for Ucharify. Completely separate infrastructure that connects to DB.",
|
"description": "Backend API for Ucharify. Completely separate infrastructure that connects to DB.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
|
||||||
"start": "node server.js",
|
|
||||||
"dev": "nodemon bin/dev.js",
|
"dev": "nodemon bin/dev.js",
|
||||||
"drop": "DROP_TABLES=true & nodemon bin/dev.js"
|
"test": "nodemon bin/test.js",
|
||||||
|
|
||||||
|
"drop:local": "DROP_TABLES=true node bin/dev.js",
|
||||||
|
"drop:test": "DROP_TABLES=true node bin/test.js",
|
||||||
|
|
||||||
|
"start": "node server.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -30,6 +33,6 @@
|
|||||||
"stripe": "^6.22.0"
|
"stripe": "^6.22.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"dotenv": "^6.2.0"
|
"dotenv-flow": "^0.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,15 +30,14 @@ app.use((req, res, next) => {
|
|||||||
db.sequelize
|
db.sequelize
|
||||||
.authenticate()
|
.authenticate()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log('Connection has been established successfully.');
|
console.log('Connection has been established successfully: ' + process.env.NODE_ENV);
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error('Unable to connect to the database:', err);
|
console.error('Unable to connect to the database:', err);
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(process.env.DROP_TABLES);
|
|
||||||
//force: true will drop the table if it already exists
|
//force: true will drop the table if it already exists
|
||||||
const drop_tables = false;
|
const drop_tables = process.env.DROP_TABLES;
|
||||||
db.sequelize.sync({ force: drop_tables }).then(() => {
|
db.sequelize.sync({ force: drop_tables }).then(() => {
|
||||||
console.log(`Drop and Resync with { force: ${drop_tables} }`);
|
console.log(`Drop and Resync with { force: ${drop_tables} }`);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user