aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/requests.ts7
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 @@
1import * as Promise from 'bluebird' 1import * as Bluebird from 'bluebird'
2import { createWriteStream } from 'fs' 2import { createWriteStream } from 'fs'
3import * as request from 'request' 3import * as request from 'request'
4import { ACTIVITY_PUB } from '../initializers' 4import { ACTIVITY_PUB } from '../initializers'
5import Bluebird = require('bluebird')
6 5
7function doRequest ( 6function 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
20function doRequestAndSaveToFile (requestOptions: request.CoreOptions & request.UriOptions, destPath: string) { 19function 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))