aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/server/plugins.ts
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils/server/plugins.ts')
-rw-r--r--shared/extra-utils/server/plugins.ts57
1 files changed, 34 insertions, 23 deletions
diff --git a/shared/extra-utils/server/plugins.ts b/shared/extra-utils/server/plugins.ts
index 83db2f6b8..864954ee7 100644
--- a/shared/extra-utils/server/plugins.ts
+++ b/shared/extra-utils/server/plugins.ts
@@ -9,6 +9,7 @@ import { PluginType } from '../../models/plugins/plugin.type'
9import { buildServerDirectory, root } from '../miscs/miscs' 9import { buildServerDirectory, root } from '../miscs/miscs'
10import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests' 10import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests'
11import { ServerInfo } from './servers' 11import { ServerInfo } from './servers'
12import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
12 13
13function listPlugins (parameters: { 14function listPlugins (parameters: {
14 url: string 15 url: string
@@ -18,9 +19,9 @@ function listPlugins (parameters: {
18 sort?: string 19 sort?: string
19 pluginType?: PluginType 20 pluginType?: PluginType
20 uninstalled?: boolean 21 uninstalled?: boolean
21 expectedStatus?: number 22 expectedStatus?: HttpStatusCode
22}) { 23}) {
23 const { url, accessToken, start, count, sort, pluginType, uninstalled, expectedStatus = 200 } = parameters 24 const { url, accessToken, start, count, sort, pluginType, uninstalled, expectedStatus = HttpStatusCode.OK_200 } = parameters
24 const path = '/api/v1/plugins' 25 const path = '/api/v1/plugins'
25 26
26 return makeGetRequest({ 27 return makeGetRequest({
@@ -47,9 +48,19 @@ function listAvailablePlugins (parameters: {
47 pluginType?: PluginType 48 pluginType?: PluginType
48 currentPeerTubeEngine?: string 49 currentPeerTubeEngine?: string
49 search?: string 50 search?: string
50 expectedStatus?: number 51 expectedStatus?: HttpStatusCode
51}) { 52}) {
52 const { url, accessToken, start, count, sort, pluginType, search, currentPeerTubeEngine, expectedStatus = 200 } = parameters 53 const {
54 url,
55 accessToken,
56 start,
57 count,
58 sort,
59 pluginType,
60 search,
61 currentPeerTubeEngine,
62 expectedStatus = HttpStatusCode.OK_200
63 } = parameters
53 const path = '/api/v1/plugins/available' 64 const path = '/api/v1/plugins/available'
54 65
55 const query: PeertubePluginIndexList = { 66 const query: PeertubePluginIndexList = {
@@ -74,9 +85,9 @@ function getPlugin (parameters: {
74 url: string 85 url: string
75 accessToken: string 86 accessToken: string
76 npmName: string 87 npmName: string
77 expectedStatus?: number 88 expectedStatus?: HttpStatusCode
78}) { 89}) {
79 const { url, accessToken, npmName, expectedStatus = 200 } = parameters 90 const { url, accessToken, npmName, expectedStatus = HttpStatusCode.OK_200 } = parameters
80 const path = '/api/v1/plugins/' + npmName 91 const path = '/api/v1/plugins/' + npmName
81 92
82 return makeGetRequest({ 93 return makeGetRequest({
@@ -92,9 +103,9 @@ function updatePluginSettings (parameters: {
92 accessToken: string 103 accessToken: string
93 npmName: string 104 npmName: string
94 settings: any 105 settings: any
95 expectedStatus?: number 106 expectedStatus?: HttpStatusCode
96}) { 107}) {
97 const { url, accessToken, npmName, settings, expectedStatus = 204 } = parameters 108 const { url, accessToken, npmName, settings, expectedStatus = HttpStatusCode.NO_CONTENT_204 } = parameters
98 const path = '/api/v1/plugins/' + npmName + '/settings' 109 const path = '/api/v1/plugins/' + npmName + '/settings'
99 110
100 return makePutBodyRequest({ 111 return makePutBodyRequest({
@@ -110,9 +121,9 @@ function getPluginRegisteredSettings (parameters: {
110 url: string 121 url: string
111 accessToken: string 122 accessToken: string
112 npmName: string 123 npmName: string
113 expectedStatus?: number 124 expectedStatus?: HttpStatusCode
114}) { 125}) {
115 const { url, accessToken, npmName, expectedStatus = 200 } = parameters 126 const { url, accessToken, npmName, expectedStatus = HttpStatusCode.OK_200 } = parameters
116 const path = '/api/v1/plugins/' + npmName + '/registered-settings' 127 const path = '/api/v1/plugins/' + npmName + '/registered-settings'
117 128
118 return makeGetRequest({ 129 return makeGetRequest({
@@ -141,9 +152,9 @@ async function testHelloWorldRegisteredSettings (server: ServerInfo) {
141function getPublicSettings (parameters: { 152function getPublicSettings (parameters: {
142 url: string 153 url: string
143 npmName: string 154 npmName: string
144 expectedStatus?: number 155 expectedStatus?: HttpStatusCode
145}) { 156}) {
146 const { url, npmName, expectedStatus = 200 } = parameters 157 const { url, npmName, expectedStatus = HttpStatusCode.OK_200 } = parameters
147 const path = '/api/v1/plugins/' + npmName + '/public-settings' 158 const path = '/api/v1/plugins/' + npmName + '/public-settings'
148 159
149 return makeGetRequest({ 160 return makeGetRequest({
@@ -156,9 +167,9 @@ function getPublicSettings (parameters: {
156function getPluginTranslations (parameters: { 167function getPluginTranslations (parameters: {
157 url: string 168 url: string
158 locale: string 169 locale: string
159 expectedStatus?: number 170 expectedStatus?: HttpStatusCode
160}) { 171}) {
161 const { url, locale, expectedStatus = 200 } = parameters 172 const { url, locale, expectedStatus = HttpStatusCode.OK_200 } = parameters
162 const path = '/plugins/translations/' + locale + '.json' 173 const path = '/plugins/translations/' + locale + '.json'
163 174
164 return makeGetRequest({ 175 return makeGetRequest({
@@ -173,9 +184,9 @@ function installPlugin (parameters: {
173 accessToken: string 184 accessToken: string
174 path?: string 185 path?: string
175 npmName?: string 186 npmName?: string
176 expectedStatus?: number 187 expectedStatus?: HttpStatusCode
177}) { 188}) {
178 const { url, accessToken, npmName, path, expectedStatus = 200 } = parameters 189 const { url, accessToken, npmName, path, expectedStatus = HttpStatusCode.OK_200 } = parameters
179 const apiPath = '/api/v1/plugins/install' 190 const apiPath = '/api/v1/plugins/install'
180 191
181 return makePostBodyRequest({ 192 return makePostBodyRequest({
@@ -192,9 +203,9 @@ function updatePlugin (parameters: {
192 accessToken: string 203 accessToken: string
193 path?: string 204 path?: string
194 npmName?: string 205 npmName?: string
195 expectedStatus?: number 206 expectedStatus?: HttpStatusCode
196}) { 207}) {
197 const { url, accessToken, npmName, path, expectedStatus = 200 } = parameters 208 const { url, accessToken, npmName, path, expectedStatus = HttpStatusCode.OK_200 } = parameters
198 const apiPath = '/api/v1/plugins/update' 209 const apiPath = '/api/v1/plugins/update'
199 210
200 return makePostBodyRequest({ 211 return makePostBodyRequest({
@@ -210,9 +221,9 @@ function uninstallPlugin (parameters: {
210 url: string 221 url: string
211 accessToken: string 222 accessToken: string
212 npmName: string 223 npmName: string
213 expectedStatus?: number 224 expectedStatus?: HttpStatusCode
214}) { 225}) {
215 const { url, accessToken, npmName, expectedStatus = 204 } = parameters 226 const { url, accessToken, npmName, expectedStatus = HttpStatusCode.NO_CONTENT_204 } = parameters
216 const apiPath = '/api/v1/plugins/uninstall' 227 const apiPath = '/api/v1/plugins/uninstall'
217 228
218 return makePostBodyRequest({ 229 return makePostBodyRequest({
@@ -230,7 +241,7 @@ function getPluginsCSS (url: string) {
230 return makeGetRequest({ 241 return makeGetRequest({
231 url, 242 url,
232 path, 243 path,
233 statusCodeExpected: 200 244 statusCodeExpected: HttpStatusCode.OK_200
234 }) 245 })
235} 246}
236 247
@@ -260,7 +271,7 @@ function getExternalAuth (options: {
260 npmVersion: string 271 npmVersion: string
261 authName: string 272 authName: string
262 query?: any 273 query?: any
263 statusCodeExpected?: number 274 statusCodeExpected?: HttpStatusCode
264}) { 275}) {
265 const { url, npmName, npmVersion, authName, statusCodeExpected, query } = options 276 const { url, npmName, npmVersion, authName, statusCodeExpected, query } = options
266 277
@@ -270,7 +281,7 @@ function getExternalAuth (options: {
270 url, 281 url,
271 path, 282 path,
272 query, 283 query,
273 statusCodeExpected: statusCodeExpected || 200, 284 statusCodeExpected: statusCodeExpected || HttpStatusCode.OK_200,
274 redirects: 0 285 redirects: 0
275 }) 286 })
276} 287}