2020-04-10 16:06:12 -04:00
|
|
|
import {Sequelize} from 'sequelize-typescript';
|
2020-04-11 05:22:55 -04:00
|
|
|
import {Author} from './author';
|
|
|
|
import {Note} from './note';
|
|
|
|
import {Revision} from './revision';
|
|
|
|
import {Temp} from './temp';
|
|
|
|
import {User} from './user';
|
|
|
|
|
|
|
|
const {cloneDeep} = require('lodash')
|
2016-04-20 06:03:55 -04:00
|
|
|
|
|
|
|
// core
|
2017-04-12 12:20:28 -04:00
|
|
|
var config = require('../config')
|
|
|
|
var logger = require('../logger')
|
2016-04-20 06:03:55 -04:00
|
|
|
|
2017-04-12 13:57:55 -04:00
|
|
|
var dbconfig = cloneDeep(config.db)
|
2019-04-12 00:05:32 -04:00
|
|
|
dbconfig.logging = config.debug ? (data) => {
|
|
|
|
logger.info(data)
|
|
|
|
} : false
|
2016-12-11 21:18:12 -05:00
|
|
|
|
2020-04-11 06:13:37 -04:00
|
|
|
export let sequelize: any;
|
2016-12-22 00:23:17 -05:00
|
|
|
|
2016-12-22 06:42:00 -05:00
|
|
|
// Heroku specific
|
2018-03-07 09:17:35 -05:00
|
|
|
if (config.dbURL) {
|
|
|
|
sequelize = new Sequelize(config.dbURL, dbconfig)
|
2017-03-08 05:45:51 -05:00
|
|
|
} else {
|
|
|
|
sequelize = new Sequelize(dbconfig.database, dbconfig.username, dbconfig.password, dbconfig)
|
|
|
|
}
|
2016-04-20 06:03:55 -04:00
|
|
|
|
2020-04-10 16:06:12 -04:00
|
|
|
sequelize.addModels([Author, Note, Revision, Temp, User]);
|
2016-04-20 06:03:55 -04:00
|
|
|
|
2020-04-11 06:13:37 -04:00
|
|
|
|
|
|
|
export {Author, Note, Revision, Temp, User};
|
|
|
|
|