From b9a3e09ad5a7673f64556d1dba122ed4c4fac980 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 7 Mar 2016 11:33:59 +0100 Subject: Prepare folders structure for angular app --- initializers/checker.js | 46 ---------------------------------------------- initializers/constants.js | 42 ------------------------------------------ initializers/database.js | 29 ----------------------------- 3 files changed, 117 deletions(-) delete mode 100644 initializers/checker.js delete mode 100644 initializers/constants.js delete mode 100644 initializers/database.js (limited to 'initializers') diff --git a/initializers/checker.js b/initializers/checker.js deleted file mode 100644 index ec7bc0ad2..000000000 --- a/initializers/checker.js +++ /dev/null @@ -1,46 +0,0 @@ -'use strict' - -var config = require('config') -var mkdirp = require('mkdirp') -var path = require('path') - -var checker = { - checkConfig: checkConfig, - createDirectoriesIfNotExist: createDirectoriesIfNotExist -} - -// Check the config files -function checkConfig () { - var required = [ 'listen.port', - 'webserver.https', 'webserver.host', 'webserver.port', - 'database.host', 'database.port', 'database.suffix', - 'storage.certs', 'storage.uploads', 'storage.logs', - 'network.friends' ] - var miss = [] - - for (var key of required) { - if (!config.has(key)) { - miss.push(key) - } - } - - return miss -} - -// Create directories for the storage if it doesn't exist -function createDirectoriesIfNotExist () { - var storages = config.get('storage') - - for (var key of Object.keys(storages)) { - var dir = storages[key] - try { - mkdirp.sync(path.join(__dirname, '..', dir)) - } catch (error) { - throw new Error('Cannot create ' + path + ':' + error) - } - } -} - -// --------------------------------------------------------------------------- - -module.exports = checker diff --git a/initializers/constants.js b/initializers/constants.js deleted file mode 100644 index 16e50443b..000000000 --- a/initializers/constants.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict' - -// API version of our pod -var API_VERSION = 'v1' - -// Score a pod has when we create it as a friend -var FRIEND_BASE_SCORE = 100 - -// Time to wait between requests to the friends -var INTERVAL = 60000 - -// Number of points we add/remove from a friend after a successful/bad request -var PODS_SCORE = { - MALUS: -10, - BONUS: 10 -} - -// Number of retries we make for the make retry requests (to friends...) -var REQUEST_RETRIES = 10 - -// Special constants for a test instance -if (isTestInstance() === true) { - FRIEND_BASE_SCORE = 20 - INTERVAL = 10000 - REQUEST_RETRIES = 2 -} - -// --------------------------------------------------------------------------- - -module.exports = { - API_VERSION: API_VERSION, - FRIEND_BASE_SCORE: FRIEND_BASE_SCORE, - INTERVAL: INTERVAL, - PODS_SCORE: PODS_SCORE, - REQUEST_RETRIES: REQUEST_RETRIES -} - -// --------------------------------------------------------------------------- - -function isTestInstance () { - return (process.env.NODE_ENV === 'test') -} diff --git a/initializers/database.js b/initializers/database.js deleted file mode 100644 index a917442ec..000000000 --- a/initializers/database.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict' - -var config = require('config') -var mongoose = require('mongoose') - -var logger = require('../helpers/logger') - -var dbname = 'peertube' + config.get('database.suffix') -var host = config.get('database.host') -var port = config.get('database.port') - -var database = { - connect: connect -} - -function connect () { - mongoose.connect('mongodb://' + host + ':' + port + '/' + dbname) - mongoose.connection.on('error', function () { - throw new Error('Mongodb connection error.') - }) - - mongoose.connection.on('open', function () { - logger.info('Connected to mongodb.') - }) -} - -// --------------------------------------------------------------------------- - -module.exports = database -- cgit v1.2.3