Skip to content

Commit

Permalink
change configs to use elelephantSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasgarcia91 committed Jun 12, 2020
1 parent 1901329 commit ada7711
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
5 changes: 1 addition & 4 deletions config/config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"development": {
"username": "postgres",
"password": "secret",
"database": "YOUR_PROJECT_NAME_HERE_development",
"host": "localhost",
"url": "YOUR_ELEPHANTSQL_URL_HERE",
"dialect": "postgres",
"operatorsAliases": "0"
},
Expand Down
23 changes: 12 additions & 11 deletions models/index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
'use strict';
"use strict";

const fs = require('fs');
const path = require('path');
const Sequelize = require('sequelize');
const fs = require("fs");
const path = require("path");
const Sequelize = require("sequelize");
const basename = path.basename(__filename);
const env = process.env.NODE_ENV || 'development';
const config = require(__dirname + '/../config/config.json')[env];
const env = process.env.NODE_ENV || "development";
const config = require(__dirname + "/../config/config.json")[env];
const db = {};

let sequelize;
if (config.use_env_variable) {
sequelize = new Sequelize(process.env[config.use_env_variable], config);
} else {
sequelize = new Sequelize(config.database, config.username, config.password, config);
sequelize = new Sequelize(config.url, config);
}

fs
.readdirSync(__dirname)
fs.readdirSync(__dirname)
.filter(file => {
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
return (
file.indexOf(".") !== 0 && file !== basename && file.slice(-3) === ".js"
);
})
.forEach(file => {
const model = sequelize['import'](path.join(__dirname, file));
const model = sequelize["import"](path.join(__dirname, file));
db[model.name] = model;
});

Expand Down
4 changes: 2 additions & 2 deletions seeders/20200318212758-users.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ module.exports = {
},
{
name: "dummy",
email: "dummy@dummy.com",
password: bcrypt.hashSync("dummy1234", SALT_ROUNDS),
email: "a@a.com",
password: bcrypt.hashSync("a", SALT_ROUNDS),
createdAt: new Date(),
updatedAt: new Date(),
},
Expand Down

0 comments on commit ada7711

Please sign in to comment.