]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/initializers/constants.js
Add tags support to server
[github/Chocobozzz/PeerTube.git] / server / initializers / constants.js
CommitLineData
9f10b292
C
1'use strict'
2
3// API version of our pod
f0f5567b 4const API_VERSION = 'v1'
9f10b292
C
5
6// Score a pod has when we create it as a friend
f0f5567b 7let FRIEND_BASE_SCORE = 100
9f10b292 8
8483b221
C
9// Time to wait between requests to the friends (10 min)
10let INTERVAL = 600000
9f10b292 11
3fe81fa7
C
12// Number of results by default for the pagination
13const PAGINATION_COUNT_DEFAULT = 15
14
9f10b292 15// Number of points we add/remove from a friend after a successful/bad request
f0f5567b 16const PODS_SCORE = {
9f10b292
C
17 MALUS: -10,
18 BONUS: 10
19}
20
21// Number of retries we make for the make retry requests (to friends...)
f0f5567b 22let REQUEST_RETRIES = 10
9f10b292 23
46246b5f
C
24// Sortable columns per schema
25const SEARCHABLE_COLUMNS = {
26 VIDEOS: [ 'name', 'magnetUri', 'podUrl', 'author' ]
27}
28
a877d5ac
C
29// Sortable columns per schema
30const SORTABLE_COLUMNS = {
31 VIDEOS: [ 'name', '-name', 'duration', '-duration', 'createdDate', '-createdDate' ]
32}
33
cbe2f7c3
C
34// Videos thumbnail size
35const THUMBNAILS_SIZE = '200x110'
36
37// Path for access to thumbnails with express router
38const THUMBNAILS_STATIC_PATH = '/static/thumbnails'
39
be587647
C
40const VIDEOS_CONSTRAINTS_FIELDS = {
41 NAME: { min: 1, max: 50 }, // Length
42 DESCRIPTION: { min: 1, max: 250 }, // Length
43 MAGNET_URI: { min: 10 }, // Length
44 DURATION: { min: 1, max: 7200 }, // Number
45 AUTHOR: { min: 3, max: 20 }, // Length
46 TAGS: { min: 1, max: 3 }, // Number of total tags
47 TAG: { min: 2, max: 10 }, // Length
48 THUMBNAIL: { min: 0, max: 20000 } // Bytes
49}
50
9f10b292
C
51// Special constants for a test instance
52if (isTestInstance() === true) {
53 FRIEND_BASE_SCORE = 20
54 INTERVAL = 10000
be587647 55 VIDEOS_CONSTRAINTS_FIELDS.DURATION.max = 14
9f10b292
C
56 REQUEST_RETRIES = 2
57}
58
59// ---------------------------------------------------------------------------
60
61module.exports = {
62 API_VERSION: API_VERSION,
63 FRIEND_BASE_SCORE: FRIEND_BASE_SCORE,
64 INTERVAL: INTERVAL,
3fe81fa7 65 PAGINATION_COUNT_DEFAULT: PAGINATION_COUNT_DEFAULT,
9f10b292 66 PODS_SCORE: PODS_SCORE,
cbe2f7c3 67 REQUEST_RETRIES: REQUEST_RETRIES,
46246b5f 68 SEARCHABLE_COLUMNS: SEARCHABLE_COLUMNS,
a877d5ac 69 SORTABLE_COLUMNS: SORTABLE_COLUMNS,
cbe2f7c3 70 THUMBNAILS_SIZE: THUMBNAILS_SIZE,
be587647
C
71 THUMBNAILS_STATIC_PATH: THUMBNAILS_STATIC_PATH,
72 VIDEOS_CONSTRAINTS_FIELDS: VIDEOS_CONSTRAINTS_FIELDS
9f10b292
C
73}
74
75// ---------------------------------------------------------------------------
76
77function isTestInstance () {
78 return (process.env.NODE_ENV === 'test')
79}