]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/utils/server/config.ts
Add hover effect on video miniature
[github/Chocobozzz/PeerTube.git] / shared / 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',
55 defaultNSFWPolicy: 'blur',
56 customizations: {
57 javascript: 'alert("coucou")',
58 css: 'body { background-color: red; }'
59 }
60 },
61 services: {
62 twitter: {
63 username: '@MySuperUsername',
64 whitelisted: true
65 }
66 },
67 cache: {
68 previews: {
69 size: 2
70 },
71 captions: {
72 size: 3
73 }
74 },
75 signup: {
76 enabled: false,
d9eaee39
JM
77 limit: 5,
78 requiresEmailVerification: false
590fb506
C
79 },
80 admin: {
81 email: 'superadmin1@example.com'
82 },
a4101923
C
83 contactForm: {
84 enabled: true
85 },
590fb506 86 user: {
bee0abff
FA
87 videoQuota: 5242881,
88 videoQuotaDaily: 318742
590fb506
C
89 },
90 transcoding: {
91 enabled: true,
14e2014a 92 allowAdditionalExtensions: true,
590fb506
C
93 threads: 1,
94 resolutions: {
95 '240p': false,
96 '360p': true,
97 '480p': true,
98 '720p': false,
99 '1080p': false
09209296
C
100 },
101 hls: {
102 enabled: false
590fb506
C
103 }
104 },
105 import: {
106 videos: {
107 http: {
108 enabled: false
a84b8fa5
C
109 },
110 torrent: {
111 enabled: false
590fb506
C
112 }
113 }
114 }
115 }
116
117 Object.assign(updateParams, newConfig)
118
119 return updateCustomConfig(url, token, updateParams)
120}
121
fd206f0b
C
122function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) {
123 const path = '/api/v1/config/custom'
124
125 return makeDeleteRequest({
126 url,
127 token,
128 path,
129 statusCodeExpected
130 })
131}
132
0e1dc3e7
C
133// ---------------------------------------------------------------------------
134
135export {
fd206f0b
C
136 getConfig,
137 getCustomConfig,
138 updateCustomConfig,
36f9424f 139 getAbout,
590fb506
C
140 deleteCustomConfig,
141 updateCustomSubConfig
0e1dc3e7 142}