diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-08-19 21:34:51 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-08-19 21:34:51 +0200 |
commit | e861452fb26553177ad4e32bfb18b4fd8a5b1816 (patch) | |
tree | 7c0cfd464709243a452b431665f5107a973df682 /server/initializers/database.js | |
parent | 5c39adb7313e0696aabb4b71196ab7b0b378c359 (diff) | |
download | PeerTube-e861452fb26553177ad4e32bfb18b4fd8a5b1816.tar.gz PeerTube-e861452fb26553177ad4e32bfb18b4fd8a5b1816.tar.zst PeerTube-e861452fb26553177ad4e32bfb18b4fd8a5b1816.zip |
Server: put config in constants
Diffstat (limited to 'server/initializers/database.js')
-rw-r--r-- | server/initializers/database.js | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/server/initializers/database.js b/server/initializers/database.js index 8626895ee..20dcc056e 100644 --- a/server/initializers/database.js +++ b/server/initializers/database.js | |||
@@ -1,8 +1,8 @@ | |||
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 |
@@ -14,17 +14,13 @@ require('../models/video') | |||
14 | // Request model needs Video model | 14 | // Request model needs Video model |
15 | require('../models/request') | 15 | require('../models/request') |
16 | 16 | ||
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 = { | 17 | const database = { |
22 | connect: connect | 18 | connect: connect |
23 | } | 19 | } |
24 | 20 | ||
25 | function connect () { | 21 | function connect () { |
26 | mongoose.Promise = global.Promise | 22 | mongoose.Promise = global.Promise |
27 | mongoose.connect('mongodb://' + host + ':' + port + '/' + dbname) | 23 | mongoose.connect('mongodb://' + constants.CONFIG.DATABASE.HOST + ':' + constants.CONFIG.DATABASE.PORT + '/' + constants.CONFIG.DATABASE.DBNAME) |
28 | mongoose.connection.on('error', function () { | 24 | mongoose.connection.on('error', function () { |
29 | throw new Error('Mongodb connection error.') | 25 | throw new Error('Mongodb connection error.') |
30 | }) | 26 | }) |