aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/requests.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-10 22:15:25 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-10 22:15:25 +0200
commit69818c9394366b954b6ba3bd697bd9d2b09f2a16 (patch)
treead199a18ec3c322460d6f9523fc383ee562554e0 /server/helpers/requests.ts
parent4d4e5cd4dca78480ec7f40e747f424cd107376a4 (diff)
downloadPeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.gz
PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.zst
PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.zip
Type functions
Diffstat (limited to 'server/helpers/requests.ts')
-rw-r--r--server/helpers/requests.ts19
1 files changed, 16 insertions, 3 deletions
diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts
index 48b1fd703..b40fc8e39 100644
--- a/server/helpers/requests.ts
+++ b/server/helpers/requests.ts
@@ -6,9 +6,15 @@ import {
6 REMOTE_SCHEME, 6 REMOTE_SCHEME,
7 CONFIG 7 CONFIG
8} from '../initializers' 8} from '../initializers'
9import { PodInstance } from '../models'
9import { sign } from './peertube-crypto' 10import { sign } from './peertube-crypto'
10 11
11function makeRetryRequest (params, callback) { 12type MakeRetryRequestParams = {
13 url: string,
14 method: 'GET'|'POST',
15 json: Object
16}
17function makeRetryRequest (params: MakeRetryRequestParams, callback: request.RequestCallback) {
12 replay( 18 replay(
13 request(params, callback), 19 request(params, callback),
14 { 20 {
@@ -20,14 +26,21 @@ function makeRetryRequest (params, callback) {
20 ) 26 )
21} 27}
22 28
23function makeSecureRequest (params, callback) { 29type MakeSecureRequestParams = {
30 method: 'GET'|'POST'
31 toPod: PodInstance
32 path: string
33 sign: boolean
34 data?: Object
35}
36function makeSecureRequest (params: MakeSecureRequestParams, callback: request.RequestCallback) {
24 const requestParams = { 37 const requestParams = {
25 url: REMOTE_SCHEME.HTTP + '://' + params.toPod.host + params.path, 38 url: REMOTE_SCHEME.HTTP + '://' + params.toPod.host + params.path,
26 json: {} 39 json: {}
27 } 40 }
28 41
29 if (params.method !== 'POST') { 42 if (params.method !== 'POST') {
30 return callback(new Error('Cannot make a secure request with a non POST method.')) 43 return callback(new Error('Cannot make a secure request with a non POST method.'), null, null)
31 } 44 }
32 45
33 // Add signature if it is specified in the params 46 // Add signature if it is specified in the params