summaryrefslogtreecommitdiff
path: root/server/db.js
blob: 6726cfb276c6547ff756aa4601b3f98655ebe791 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var Sequelize = require("sequelize"),
  config = require("../config.json"),
  pg = require('pg');

var db = module.exports = {}

console.log(process.env.DATABASE_URL)

var DATABASE_URL = process.env.DATABASE_URL || ('postgres://postgres:postgres@localhost:5432/' + config.name)

var match = DATABASE_URL.match(/postgres:\/\/([^:]+):([^@]+)@([^:]+):(\d+)\/(.+)/)

db.sequelize = new Sequelize(match[5], match[1], match[2], {
  dialect: 'postgres',
  protocol: 'postgres',
	port:     match[4],
	host:     match[3],
	logging:  true //false
})