]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/extra-utils/server/config.ts
Add more CLI tests
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / server / config.ts
CommitLineData
d175a6f7 1import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../requests/requests'
d4681c00 2import { CustomConfig } from '../../models/server/custom-config.model'
0e1dc3e7
C
3
4function getConfig (url: string) {
5 const path = '/api/v1/config'
6
36f9424f
C
7 return makeGetRequest({
8 url,
9 path,
10 statusCodeExpected: 200
11 })
12}
13
14function getAbout (url: string) {
15 const path = '/api/v1/config/about'
16
17 return makeGetRequest({
18 url,
19 path,
20 statusCodeExpected: 200
21 })
0e1dc3e7
C
22}
23
fd206f0b
C
24function getCustomConfig (url: string, token: string, statusCodeExpected = 200) {
25 const path = '/api/v1/config/custom'
26
27 return makeGetRequest({
28 url,
29 token,
30 path,
31 statusCodeExpected
32 })
33}
34
35function updateCustomConfig (url: string, token: string, newCustomConfig: CustomConfig, statusCodeExpected = 200) {
36 const path = '/api/v1/config/custom'
37
38 return makePutBodyRequest({
39 url,
40 token,
41 path,
42 fields: newCustomConfig,
43 statusCodeExpected
44 })
45}
46
590fb506
C
47function updateCustomSubConfig (url: string, token: string, newConfig: any) {
48 const updateParams: CustomConfig = {
49 instance: {
50 name: 'PeerTube updated',
51 shortDescription: 'my short description',
52 description: 'my super description',
53 terms: 'my super terms',
54 defaultClientRoute: '/videos/recently-added',
f8802489 55 isNSFW: true,
590fb506
C
56 defaultNSFWPolicy: 'blur',
57 customizations: {
58 javascript: 'alert("coucou")',
59 css: 'body { background-color: red; }'
60 }
61 },
62 services: {
63 twitter: {
64 username: '@MySuperUsername',
65 whitelisted: true
66 }
67 },
68 cache: {
69 previews: {
70 size: 2
71 },
72 captions: {
73 size: 3
74 }
75 },
76 signup: {
77 enabled: false,
d9eaee39
JM
78 limit: 5,
79 requiresEmailVerification: false
590fb506
C
80 },
81 admin: {
82 email: 'superadmin1@example.com'
83 },
a4101923
C
84 contactForm: {
85 enabled: true
86 },
590fb506 87 user: {
bee0abff
FA
88 videoQuota: 5242881,
89 videoQuotaDaily: 318742
590fb506
C
90 },
91 transcoding: {
92 enabled: true,
14e2014a 93 allowAdditionalExtensions: true,
536598cf 94 allowAudioFiles: true,
590fb506
C
95 threads: 1,
96 resolutions: {
97 '240p': false,
98 '360p': true,
99 '480p': true,
100 '720p': false,
db714ab4
C
101 '1080p': false,
102 '2160p': false
09209296
C
103 },
104 hls: {
105 enabled: false
590fb506
C
106 }
107 },
108 import: {
109 videos: {
110 http: {
111 enabled: false
a84b8fa5
C
112 },
113 torrent: {
114 enabled: false
590fb506
C
115 }
116 }
7ccddd7b
JM
117 },
118 autoBlacklist: {
119 videos: {
120 ofUsers: {
121 enabled: false
122 }
123 }
5b9c965d
C
124 },
125 followers: {
126 instance: {
14893eb7
C
127 enabled: true,
128 manualApproval: false
5b9c965d 129 }
590fb506
C
130 }
131 }
132
133 Object.assign(updateParams, newConfig)
134
135 return updateCustomConfig(url, token, updateParams)
136}
137
fd206f0b
C
138function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) {
139 const path = '/api/v1/config/custom'
140
141 return makeDeleteRequest({
142 url,
143 token,
144 path,
145 statusCodeExpected
146 })
147}
148
0e1dc3e7
C
149// ---------------------------------------------------------------------------
150
151export {
fd206f0b
C
152 getConfig,
153 getCustomConfig,
154 updateCustomConfig,
36f9424f 155 getAbout,
590fb506
C
156 deleteCustomConfig,
157 updateCustomSubConfig
0e1dc3e7 158}