public
Created

Sequelize Locomotive initializer.

  • Download Gist
gistfile1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
module.exports = function() {
console.log('ENVIRONMENT');
console.log(this.env);
switch(this.env) {
case 'development':
var sequelize = new Sequelize('paragon_development', 'root', null);
break;
case 'production':
if (process.env['HEROKU_POSTGRESQL_COPPER_URL']) {
var url = require('url').parse(process.env['HEROKU_POSTGRESQL_COPPER_URL']);
console.log(url);
var pgOpts = {
pathname: url.pathname,
port: url.port,
host: url.hostname,
user: url.auth.split(':')[0],
pass: url.auth.split(':')[1]
};
var sequelize = new Sequelize(pgOpts.pathname, pgOpts.user , pgOpts.pass, {
host: pgOpts.hostname,
port: pgOpts.port,
dialect: 'postgres',
// custom protocol
// - default: 'tcp'
// - added in: v1.5.0
// - postgres only, useful for heroku
protocol: null
});
}
break;
}

Heroku var:
HEROKU_POSTGRESQL_JADE_URL: postgres://sgcggjfwldxmvj:PeLXfyFqOBomqjny8bGRcMiNGn@ec2-54-243-181-115.compute-1.amazonaws.com:5432/ddr742teg2dnho

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.