3 // API version of our pod
4 const API_VERSION
= 'v1'
6 // Score a pod has when we create it as a friend
12 // Time to wait between requests to the friends (10 min)
15 const OAUTH_LIFETIME
= {
16 ACCESS_TOKEN: 3600 * 4, // 4 hours
17 REFRESH_TOKEN: 1209600 // 2 weeks
20 // Number of results by default for the pagination
21 const PAGINATION_COUNT_DEFAULT
= 15
23 // Number of points we add/remove from a friend after a successful/bad request
29 // Number of requests in parallel we can make
30 const REQUESTS_IN_PARALLEL
= 10
32 // How many requests we put in request (request scheduler)
33 const REQUESTS_LIMIT
= 10
35 // Number of requests to retry for replay requests module
36 const RETRY_REQUESTS
= 5
38 // Sortable columns per schema
39 const SEARCHABLE_COLUMNS
= {
40 VIDEOS: [ 'name', 'magnetUri', 'podUrl', 'author', 'tags' ]
43 // Seeds in parallel we send to electron when "seed all"
44 // Once a video is in seeding state we seed another video etc
45 const SEEDS_IN_PARALLEL
= 3
47 // Sortable columns per schema
48 const SORTABLE_COLUMNS
= {
49 VIDEOS: [ 'name', '-name', 'duration', '-duration', 'createdDate', '-createdDate' ]
52 // Express static paths (router)
53 const STATIC_PATHS
= {
54 THUMBNAILS: '/static/thumbnails',
55 TORRENTS: '/static/torrents/',
56 WEBSEED: '/static/webseed/'
59 // Videos thumbnail size
60 const THUMBNAILS_SIZE
= '200x110'
62 const VIDEOS_CONSTRAINTS_FIELDS
= {
63 NAME: { min: 3, max: 50 }, // Length
64 DESCRIPTION: { min: 3, max: 250 }, // Length
65 MAGNET_URI: { min: 10 }, // Length
66 DURATION: { min: 1, max: 7200 }, // Number
67 AUTHOR: { min: 3, max: 20 }, // Length
68 TAGS: { min: 1, max: 3 }, // Number of total tags
69 TAG: { min: 2, max: 10 }, // Length
70 THUMBNAIL: { min: 2, max: 30 },
71 THUMBNAIL64: { min: 0, max: 20000 } // Bytes
74 // Special constants for a test instance
75 if (isTestInstance() === true) {
76 FRIEND_SCORE
.BASE
= 20
78 VIDEOS_CONSTRAINTS_FIELDS
.DURATION
.max
= 14
81 // ---------------------------------------------------------------------------
84 API_VERSION: API_VERSION
,
85 FRIEND_SCORE: FRIEND_SCORE
,
87 OAUTH_LIFETIME: OAUTH_LIFETIME
,
88 PAGINATION_COUNT_DEFAULT: PAGINATION_COUNT_DEFAULT
,
89 PODS_SCORE: PODS_SCORE
,
90 REQUESTS_IN_PARALLEL: REQUESTS_IN_PARALLEL
,
91 REQUESTS_LIMIT: REQUESTS_LIMIT
,
92 RETRY_REQUESTS: RETRY_REQUESTS
,
93 SEARCHABLE_COLUMNS: SEARCHABLE_COLUMNS
,
94 SEEDS_IN_PARALLEL: SEEDS_IN_PARALLEL
,
95 SORTABLE_COLUMNS: SORTABLE_COLUMNS
,
96 STATIC_PATHS: STATIC_PATHS
,
97 THUMBNAILS_SIZE: THUMBNAILS_SIZE
,
98 VIDEOS_CONSTRAINTS_FIELDS: VIDEOS_CONSTRAINTS_FIELDS
101 // ---------------------------------------------------------------------------
103 function isTestInstance () {
104 return (process
.env
.NODE_ENV
=== 'test')