diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-10-02 15:39:09 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-10-02 15:39:09 +0200 |
commit | a6375e69668ea42e19531c6bc68dcd37f3f7cbd7 (patch) | |
tree | 03204a408d56311692c3528bedcf95d2455e94f2 /server/initializers/database.js | |
parent | 052937db8a8d282eccdbdf38d487ed8d85d3c0a7 (diff) | |
parent | c4403b29ad4db097af528a7f04eea07e0ed320d0 (diff) | |
download | PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.tar.gz PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.tar.zst PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.zip |
Merge branch 'master' into webseed-merged
Diffstat (limited to 'server/initializers/database.js')
-rw-r--r-- | server/initializers/database.js | 11 |
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 | ||
3 | const config = require('config') | ||
4 | const mongoose = require('mongoose') | 3 | const mongoose = require('mongoose') |
5 | 4 | ||
5 | const constants = require('../initializers/constants') | ||
6 | const logger = require('../helpers/logger') | 6 | const logger = require('../helpers/logger') |
7 | 7 | ||
8 | // Bootstrap models | 8 | // Bootstrap models |
9 | require('../models/application') | ||
10 | require('../models/oauth-token') | ||
9 | require('../models/user') | 11 | require('../models/user') |
10 | require('../models/oauth-client') | 12 | require('../models/oauth-client') |
11 | require('../models/oauth-token') | ||
12 | require('../models/pods') | 13 | require('../models/pods') |
13 | require('../models/video') | 14 | require('../models/video') |
14 | // Request model needs Video model | 15 | // Request model needs Video model |
15 | require('../models/request') | 16 | require('../models/request') |
16 | 17 | ||
17 | const dbname = 'peertube' + config.get('database.suffix') | ||
18 | const host = config.get('database.host') | ||
19 | const port = config.get('database.port') | ||
20 | |||
21 | const database = { | 18 | const database = { |
22 | connect: connect | 19 | connect: connect |
23 | } | 20 | } |
24 | 21 | ||
25 | function connect () { | 22 | function 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 | }) |