all basic config done
This commit is contained in:
+4
-2
@@ -55,8 +55,10 @@ typings/
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
# local .env* files
|
||||
.env*
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
require('dotenv/config');
|
||||
|
||||
module.exports = {
|
||||
local: {
|
||||
development: {
|
||||
username: 'root',
|
||||
password: 'water',
|
||||
database: 'ucharify',
|
||||
host: 'localhost',
|
||||
dialect: 'mysql'
|
||||
},
|
||||
staging: {
|
||||
test: {
|
||||
username: 'root',
|
||||
password: null,
|
||||
database: 'database_test',
|
||||
|
||||
@@ -7,7 +7,7 @@ const Sequelize = require('sequelize'),
|
||||
UserModel = require('../models/user.model.js'),
|
||||
PaymentPlanModel = require('../models/paymentplan.model'),
|
||||
ChargeModel = require('../models/charge.model');
|
||||
associate = require('./associate');
|
||||
associate = require('./associate');
|
||||
|
||||
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');
|
||||
|
||||
@@ -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==",
|
||||
"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": {
|
||||
"version": "2.0.1",
|
||||
"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.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "node server.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": {
|
||||
"type": "git",
|
||||
@@ -30,6 +33,6 @@
|
||||
"stripe": "^6.22.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"dotenv": "^6.2.0"
|
||||
"dotenv-flow": "^0.2.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,15 +30,14 @@ app.use((req, res, next) => {
|
||||
db.sequelize
|
||||
.authenticate()
|
||||
.then(() => {
|
||||
console.log('Connection has been established successfully.');
|
||||
console.log('Connection has been established successfully: ' + process.env.NODE_ENV);
|
||||
})
|
||||
.catch(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
|
||||
const drop_tables = false;
|
||||
const drop_tables = process.env.DROP_TABLES;
|
||||
db.sequelize.sync({ force: drop_tables }).then(() => {
|
||||
console.log(`Drop and Resync with { force: ${drop_tables} }`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user