aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/database.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/database.js')
-rw-r--r--server/initializers/database.js11
1 files changed, 4 insertions, 7 deletions
diff --git a/server/initializers/database.js b/server/initializers/database.js
index 8626895ee..45c8a240d 100644
--- a/server/initializers/database.js
+++ b/server/initializers/database.js
@@ -1,30 +1,27 @@
1'use strict' 1'use strict'
2 2
3const config = require('config')
4const mongoose = require('mongoose') 3const mongoose = require('mongoose')
5 4
5const constants = require('../initializers/constants')
6const logger = require('../helpers/logger') 6const logger = require('../helpers/logger')
7 7
8// Bootstrap models 8// Bootstrap models
9require('../models/application')
10require('../models/oauth-token')
9require('../models/user') 11require('../models/user')
10require('../models/oauth-client') 12require('../models/oauth-client')
11require('../models/oauth-token')
12require('../models/pods') 13require('../models/pods')
13require('../models/video') 14require('../models/video')
14// Request model needs Video model 15// Request model needs Video model
15require('../models/request') 16require('../models/request')
16 17
17const dbname = 'peertube' + config.get('database.suffix')
18const host = config.get('database.host')
19const port = config.get('database.port')
20
21const database = { 18const database = {
22 connect: connect 19 connect: connect
23} 20}
24 21
25function connect () { 22function connect () {
26 mongoose.Promise = global.Promise 23 mongoose.Promise = global.Promise
27 mongoose.connect('mongodb://' + host + ':' + port + '/' + dbname) 24 mongoose.connect('mongodb://' + constants.CONFIG.DATABASE.HOST + ':' + constants.CONFIG.DATABASE.PORT + '/' + constants.CONFIG.DATABASE.DBNAME)
28 mongoose.connection.on('error', function () { 25 mongoose.connection.on('error', function () {
29 throw new Error('Mongodb connection error.') 26 throw new Error('Mongodb connection error.')
30 }) 27 })