X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Finitializers%2Fconstants.js;h=0af7aca3c39040cb0ed1d61411c0f6a3b0477739;hb=67bf9b96bbcd92b069fe86d9223fe0f8b9c6e677;hp=b1d0333771fc429b487814217e8b1a2a031bd02f;hpb=9f6bae3a9db13bf827f8aaff903aac06ec430903;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/initializers/constants.js b/server/initializers/constants.js index b1d033377..0af7aca3c 100644 --- a/server/initializers/constants.js +++ b/server/initializers/constants.js @@ -13,13 +13,13 @@ const PAGINATION_COUNT_DEFAULT = 15 // Sortable columns per schema const SEARCHABLE_COLUMNS = { - VIDEOS: [ 'name', 'magnetUri', 'podUrl', 'author', 'tags' ] + VIDEOS: [ 'name', 'magnetUri', 'host', 'author', 'tags' ] } // Sortable columns per schema const SORTABLE_COLUMNS = { - USERS: [ 'username', '-username', 'createdDate', '-createdDate' ], - VIDEOS: [ 'name', '-name', 'duration', '-duration', 'createdDate', '-createdDate' ] + USERS: [ 'username', '-username', 'createdAt', '-createdAt' ], + VIDEOS: [ 'name', '-name', 'duration', '-duration', 'createdAt', '-createdAt' ] } const OAUTH_LIFETIME = { @@ -30,27 +30,33 @@ const OAUTH_LIFETIME = { // --------------------------------------------------------------------------- const CONFIG = { + LISTEN: { + PORT: config.get('listen.port') + }, DATABASE: { DBNAME: 'peertube' + config.get('database.suffix'), - HOST: config.get('database.host'), - PORT: config.get('database.port') - }, - ELECTRON: { - DEBUG: config.get('electron.debug') + HOSTNAME: config.get('database.hostname'), + PORT: config.get('database.port'), + USERNAME: config.get('database.username'), + PASSWORD: config.get('database.password') }, STORAGE: { CERT_DIR: path.join(__dirname, '..', '..', config.get('storage.certs')), LOG_DIR: path.join(__dirname, '..', '..', config.get('storage.logs')), - UPLOAD_DIR: path.join(__dirname, '..', '..', config.get('storage.uploads')), - THUMBNAILS_DIR: path.join(__dirname, '..', '..', config.get('storage.thumbnails')) + VIDEOS_DIR: path.join(__dirname, '..', '..', config.get('storage.videos')), + THUMBNAILS_DIR: path.join(__dirname, '..', '..', config.get('storage.thumbnails')), + PREVIEWS_DIR: path.join(__dirname, '..', '..', config.get('storage.previews')), + TORRENTS_DIR: path.join(__dirname, '..', '..', config.get('storage.torrents')) }, WEBSERVER: { SCHEME: config.get('webserver.https') === true ? 'https' : 'http', - HOST: config.get('webserver.host'), + WS: config.get('webserver.https') === true ? 'wss' : 'ws', + HOSTNAME: config.get('webserver.hostname'), PORT: config.get('webserver.port') } } -CONFIG.WEBSERVER.URL = CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOST + ':' + CONFIG.WEBSERVER.PORT +CONFIG.WEBSERVER.URL = CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT +CONFIG.WEBSERVER.HOST = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT // --------------------------------------------------------------------------- @@ -62,7 +68,8 @@ const CONSTRAINTS_FIELDS = { VIDEOS: { NAME: { min: 3, max: 50 }, // Length DESCRIPTION: { min: 3, max: 250 }, // Length - MAGNET_URI: { min: 10 }, // Length + EXTNAME: [ '.mp4', '.ogv', '.webm' ], + INFO_HASH: { min: 40, max: 40 }, // Length, infohash is 20 bytes length but we represent it in hexa so 20 * 2 DURATION: { min: 1, max: 7200 }, // Number TAGS: { min: 1, max: 3 }, // Number of total tags TAG: { min: 2, max: 10 }, // Length @@ -81,21 +88,7 @@ const FRIEND_SCORE = { // --------------------------------------------------------------------------- -const MONGO_MIGRATION_SCRIPTS = [ - { - script: '0005-create-application', - version: 5 - }, - { - script: '0010-users-password', - version: 10 - }, - { - script: '0015-admin-role', - version: 15 - } -] -const LAST_MONGO_SCHEMA_VERSION = 15 +const LAST_MIGRATION_VERSION = 0 // --------------------------------------------------------------------------- @@ -117,26 +110,40 @@ const REQUESTS_LIMIT = 10 // Number of requests to retry for replay requests module const RETRY_REQUESTS = 5 +const REQUEST_ENDPOINTS = { + VIDEOS: 'videos' +} + // --------------------------------------------------------------------------- +const REMOTE_SCHEME = { + HTTP: 'https', + WS: 'wss' +} + // Password encryption const BCRYPT_SALT_SIZE = 10 +// Express static paths (router) +const STATIC_PATHS = { + PREVIEWS: '/static/previews/', + THUMBNAILS: '/static/thumbnails/', + TORRENTS: '/static/torrents/', + WEBSEED: '/static/webseed/' +} + +// Cache control +let STATIC_MAX_AGE = '30d' + // Videos thumbnail size const THUMBNAILS_SIZE = '200x110' - -// Path for access to thumbnails with express router -const THUMBNAILS_STATIC_PATH = '/static/thumbnails' +const PREVIEWS_SIZE = '640x480' const USER_ROLES = { ADMIN: 'admin', USER: 'user' } -// Seeds in parallel we send to electron when "seed all" -// Once a video is in seeding state we seed another video etc -const SEEDS_IN_PARALLEL = 3 - // --------------------------------------------------------------------------- // Special constants for a test instance @@ -144,6 +151,9 @@ if (isTestInstance() === true) { CONSTRAINTS_FIELDS.VIDEOS.DURATION.max = 14 FRIEND_SCORE.BASE = 20 REQUESTS_INTERVAL = 10000 + REMOTE_SCHEME.HTTP = 'http' + REMOTE_SCHEME.WS = 'ws' + STATIC_MAX_AGE = 0 } // --------------------------------------------------------------------------- @@ -154,25 +164,28 @@ module.exports = { CONFIG, CONSTRAINTS_FIELDS, FRIEND_SCORE, - LAST_MONGO_SCHEMA_VERSION, - MONGO_MIGRATION_SCRIPTS, + LAST_MIGRATION_VERSION, OAUTH_LIFETIME, PAGINATION_COUNT_DEFAULT, PODS_SCORE, + PREVIEWS_SIZE, + REMOTE_SCHEME, + REQUEST_ENDPOINTS, REQUESTS_IN_PARALLEL, REQUESTS_INTERVAL, REQUESTS_LIMIT, RETRY_REQUESTS, SEARCHABLE_COLUMNS, - SEEDS_IN_PARALLEL, SORTABLE_COLUMNS, + STATIC_MAX_AGE, + STATIC_PATHS, THUMBNAILS_SIZE, - THUMBNAILS_STATIC_PATH, USER_ROLES } // --------------------------------------------------------------------------- +// This method exists in utils module but we want to let the constants module independent function isTestInstance () { return (process.env.NODE_ENV === 'test') }