diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-15 11:10:46 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-15 11:28:41 +0100 |
commit | 6b2ef589ed8ef5d253f6213e1bb275cbe135f2b4 (patch) | |
tree | 78ca2afa162c9da0b4e013644f3a8c5b49e26436 /server/helpers | |
parent | 633868bc2c638ab15c31513bc0da7de92944bffc (diff) | |
download | PeerTube-6b2ef589ed8ef5d253f6213e1bb275cbe135f2b4.tar.gz PeerTube-6b2ef589ed8ef5d253f6213e1bb275cbe135f2b4.tar.zst PeerTube-6b2ef589ed8ef5d253f6213e1bb275cbe135f2b4.zip |
Prepare production workflow
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/requests.ts | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index e8d77b15b..eb8a12868 100644 --- a/server/helpers/requests.ts +++ b/server/helpers/requests.ts | |||
@@ -1,8 +1,7 @@ | |||
1 | import * as Promise from 'bluebird' | 1 | import * as Bluebird from 'bluebird' |
2 | import { createWriteStream } from 'fs' | 2 | import { createWriteStream } from 'fs' |
3 | import * as request from 'request' | 3 | import * as request from 'request' |
4 | import { ACTIVITY_PUB } from '../initializers' | 4 | import { ACTIVITY_PUB } from '../initializers' |
5 | import Bluebird = require('bluebird') | ||
6 | 5 | ||
7 | function doRequest ( | 6 | function doRequest ( |
8 | requestOptions: request.CoreOptions & request.UriOptions & { activityPub?: boolean } | 7 | requestOptions: request.CoreOptions & request.UriOptions & { activityPub?: boolean } |
@@ -12,13 +11,13 @@ function doRequest ( | |||
12 | requestOptions.headers['accept'] = ACTIVITY_PUB.ACCEPT_HEADER | 11 | requestOptions.headers['accept'] = ACTIVITY_PUB.ACCEPT_HEADER |
13 | } | 12 | } |
14 | 13 | ||
15 | return new Promise<{ response: request.RequestResponse, body: any }>((res, rej) => { | 14 | return new Bluebird<{ response: request.RequestResponse, body: any }>((res, rej) => { |
16 | request(requestOptions, (err, response, body) => err ? rej(err) : res({ response, body })) | 15 | request(requestOptions, (err, response, body) => err ? rej(err) : res({ response, body })) |
17 | }) | 16 | }) |
18 | } | 17 | } |
19 | 18 | ||
20 | function doRequestAndSaveToFile (requestOptions: request.CoreOptions & request.UriOptions, destPath: string) { | 19 | function doRequestAndSaveToFile (requestOptions: request.CoreOptions & request.UriOptions, destPath: string) { |
21 | return new Promise<request.RequestResponse>((res, rej) => { | 20 | return new Bluebird<request.RequestResponse>((res, rej) => { |
22 | request(requestOptions) | 21 | request(requestOptions) |
23 | .on('response', response => res(response as request.RequestResponse)) | 22 | .on('response', response => res(response as request.RequestResponse)) |
24 | .on('error', err => rej(err)) | 23 | .on('error', err => rej(err)) |