]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/initializers/database.js
Add check for the author username length
[github/Chocobozzz/PeerTube.git] / server / initializers / database.js
CommitLineData
9f10b292 1'use strict'
8c308c2b 2
f0f5567b
C
3const config = require('config')
4const mongoose = require('mongoose')
8c308c2b 5
f0f5567b 6const logger = require('../helpers/logger')
8c308c2b 7
f0f5567b
C
8const dbname = 'peertube' + config.get('database.suffix')
9const host = config.get('database.host')
10const port = config.get('database.port')
8c308c2b 11
f0f5567b 12const database = {
9f10b292
C
13 connect: connect
14}
c45f7f84 15
9f10b292
C
16function connect () {
17 mongoose.connect('mongodb://' + host + ':' + port + '/' + dbname)
18 mongoose.connection.on('error', function () {
ac2f99eb 19 throw new Error('Mongodb connection error.')
9f10b292 20 })
c45f7f84 21
9f10b292
C
22 mongoose.connection.on('open', function () {
23 logger.info('Connected to mongodb.')
24 })
25}
c45f7f84 26
9f10b292 27// ---------------------------------------------------------------------------
8c308c2b 28
9f10b292 29module.exports = database