Skip to content

Commit 045d941

Browse files
authored
Remove request and request-promise from dev dependencies (#5077)
* removes from emailverificationtoken spec * updates winston * Updates ValidationAndPasswordsReset * Use local request in schemas * Removes request in rest.spec * Removes request from PushRouter0 * removes request from public API * removes request from index.spec * Removes request form parse.push spec * removes request from ParseInstallation spec * Removes from ParseHooks * removes request from ParseGlobalConfig.spec * Removes request from ParseAPI.spec.js * removes request from LogsRouter * removes in features * Filters undefined headers instead of crashing * Removes request from ParseUser spec * Removes usage of request in ParseFile.spec.js * Removes request from AuthAdapters.js * removes request-promise from ParseGeoPoint.spec * Removes request-promise from ParseQuery spec * remove request-promise from UserPII * removes request-promise from EnableExpressErrorHandler * Updates RevocableSessionUpgrade spec * Update RestQuery * Removes read preferenceOptionM * ensure we forward auth from URL * use request in CloudCode.spec.js * Removes request-promise from JobSchedule.spec * Removes rp from VerifyUserPassword.spec.js * Removes rp from PasswordPolicy spec * Removes rp from ParsePolygon spec * Removes rp from fullTextSearch spec * Removes rp from PArseQuery.Aggregate * Ensure we properly forward errors * Removes request and request-promise
1 parent 93a0017 commit 045d941

35 files changed

+5950
-8382
lines changed

package-lock.json

Lines changed: 1358 additions & 3375 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@
6969
"nodemon": "1.18.4",
7070
"nyc": "^12.0.2",
7171
"prettier": "1.14.3",
72-
"request": "2.88.0",
73-
"request-promise": "4.2.2",
7472
"supports-color": "^5.4.0"
7573
},
7674
"scripts": {

spec/AuthenticationAdapters.spec.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const request = require('request');
1+
const request = require('../lib/request');
22
const Config = require('../lib/Config');
33
const defaultColumns = require('../lib/Controllers/SchemaController')
44
.defaultColumns;
@@ -143,6 +143,7 @@ describe('AuthenticationProviders', function() {
143143
};
144144

145145
const options = {
146+
method: 'POST',
146147
headers: {
147148
'X-Parse-Application-Id': 'test',
148149
'X-Parse-REST-API-Key': 'rest',
@@ -152,17 +153,23 @@ describe('AuthenticationProviders', function() {
152153
},
153154
url: 'http://localhost:8378/1/users',
154155
body: jsonBody,
155-
json: true,
156156
};
157-
158-
return new Promise(resolve => {
159-
request.post(options, (err, res, body) => {
160-
resolve({ err, res, body });
157+
return request(options)
158+
.then(response => {
159+
if (callback) {
160+
callback(null, response, response.data);
161+
}
162+
return {
163+
res: response,
164+
body: response.data,
165+
};
166+
})
167+
.catch(error => {
161168
if (callback) {
162-
callback(err, res, body);
169+
callback(error);
163170
}
171+
throw error;
164172
});
165-
});
166173
};
167174

168175
it('should create user with REST API', done => {
@@ -226,9 +233,9 @@ describe('AuthenticationProviders', function() {
226233
.then(user => {
227234
return createOAuthUserWithSessionToken(user.getSessionToken());
228235
})
229-
.then(({ body }) => {
230-
expect(body.code).toBe(208);
231-
expect(body.error).toBe('this auth is already used');
236+
.then(fail, ({ data }) => {
237+
expect(data.code).toBe(208);
238+
expect(data.error).toBe('this auth is already used');
232239
done();
233240
})
234241
.catch(done.fail);

spec/CloudCode.spec.js

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
const Parse = require('parse/node');
3-
const rp = require('request-promise');
3+
const request = require('../lib/request');
44
const InMemoryCacheAdapter = require('../lib/Adapters/Cache/InMemoryCacheAdapter')
55
.InMemoryCacheAdapter;
66

@@ -880,26 +880,23 @@ describe('Cloud Code', () => {
880880
})
881881
.then(user => {
882882
session1 = user.getSessionToken();
883-
return rp({
884-
uri: 'http://localhost:8378/1/login?username=test&password=moon-y',
885-
json: true,
883+
return request({
884+
url: 'http://localhost:8378/1/login?username=test&password=moon-y',
886885
headers: {
887886
'X-Parse-Application-Id': 'test',
888887
'X-Parse-REST-API-Key': 'rest',
889888
},
890889
});
891890
})
892-
.then(body => {
893-
session2 = body.sessionToken;
894-
891+
.then(response => {
892+
session2 = response.data.sessionToken;
895893
//Ensure both session tokens are in the cache
896-
return Parse.Cloud.run('checkStaleUser');
894+
return Parse.Cloud.run('checkStaleUser', { sessionToken: session2 });
897895
})
898896
.then(() =>
899-
rp({
897+
request({
900898
method: 'POST',
901-
uri: 'http://localhost:8378/1/functions/checkStaleUser',
902-
json: true,
899+
url: 'http://localhost:8378/1/functions/checkStaleUser',
903900
headers: {
904901
'X-Parse-Application-Id': 'test',
905902
'X-Parse-REST-API-Key': 'rest',
@@ -922,22 +919,21 @@ describe('Cloud Code', () => {
922919
return user.save();
923920
})
924921
.then(() =>
925-
rp({
922+
request({
926923
method: 'POST',
927-
uri: 'http://localhost:8378/1/functions/checkStaleUser',
928-
json: true,
924+
url: 'http://localhost:8378/1/functions/checkStaleUser',
929925
headers: {
930926
'X-Parse-Application-Id': 'test',
931927
'X-Parse-REST-API-Key': 'rest',
932928
'X-Parse-Session-Token': session2,
933929
},
934930
})
935931
)
936-
.then(body => {
937-
expect(body.result).toEqual('second data');
932+
.then(response => {
933+
expect(response.data.result).toEqual('second data');
938934
done();
939935
})
940-
.catch(done.fail);
936+
.catch(e => done.fail(e));
941937
});
942938

943939
it('trivial beforeSave should not affect fetched pointers (regression test for #1238)', done => {
@@ -1196,7 +1192,8 @@ describe('Cloud Code', () => {
11961192
Parse.Cloud.job('myJob', () => {});
11971193
}).not.toThrow();
11981194

1199-
rp.post({
1195+
request({
1196+
method: 'POST',
12001197
url: 'http://localhost:8378/1/jobs/myJob',
12011198
headers: {
12021199
'X-Parse-Application-Id': Parse.applicationId,
@@ -1218,7 +1215,8 @@ describe('Cloud Code', () => {
12181215
Parse.Cloud.job('myJob', () => {});
12191216
}).not.toThrow();
12201217

1221-
rp.post({
1218+
request({
1219+
method: 'POST',
12221220
url: 'http://localhost:8378/1/jobs/myJob',
12231221
headers: {
12241222
'X-Parse-Application-Id': Parse.applicationId,
@@ -1230,7 +1228,7 @@ describe('Cloud Code', () => {
12301228
done();
12311229
},
12321230
err => {
1233-
expect(err.statusCode).toBe(403);
1231+
expect(err.status).toBe(403);
12341232
done();
12351233
}
12361234
);
@@ -1248,7 +1246,8 @@ describe('Cloud Code', () => {
12481246
});
12491247
}).not.toThrow();
12501248

1251-
rp.post({
1249+
request({
1250+
method: 'POST',
12521251
url: 'http://localhost:8378/1/jobs/myJob',
12531252
headers: {
12541253
'X-Parse-Application-Id': Parse.applicationId,
@@ -1275,7 +1274,8 @@ describe('Cloud Code', () => {
12751274
});
12761275
}).not.toThrow();
12771276

1278-
rp.post({
1277+
request({
1278+
method: 'POST',
12791279
url: `http://${Parse.applicationId}:${
12801280
Parse.masterKey
12811281
}@localhost:8378/1/jobs/myJob`,
@@ -1317,7 +1317,8 @@ describe('Cloud Code', () => {
13171317
return promise;
13181318
});
13191319

1320-
rp.post({
1320+
request({
1321+
method: 'POST',
13211322
url: 'http://localhost:8378/1/jobs/myJob',
13221323
headers: {
13231324
'X-Parse-Application-Id': Parse.applicationId,
@@ -1351,7 +1352,8 @@ describe('Cloud Code', () => {
13511352
return promise;
13521353
});
13531354

1354-
rp.post({
1355+
request({
1356+
method: 'POST',
13551357
url: 'http://localhost:8378/1/jobs/myJob',
13561358
headers: {
13571359
'X-Parse-Application-Id': Parse.applicationId,
@@ -1580,7 +1582,7 @@ describe('beforeFind hooks', () => {
15801582
return Parse.Query.or(req.query, otherQuery);
15811583
});
15821584

1583-
rp.get({
1585+
request({
15841586
url: 'http://localhost:8378/1/classes/MyObject',
15851587
headers: {
15861588
'X-Parse-Application-Id': Parse.applicationId,
@@ -1639,15 +1641,16 @@ describe('beforeFind hooks', () => {
16391641
const obj = new Parse.Object('MyObject');
16401642
obj.set('secretField', 'SSID');
16411643
obj.save().then(function() {
1642-
rp({
1644+
request({
16431645
method: 'GET',
1644-
uri: 'http://localhost:8378/1/classes/MyObject/' + obj.id,
1646+
url: 'http://localhost:8378/1/classes/MyObject/' + obj.id,
16451647
headers: {
16461648
'X-Parse-Application-Id': 'test',
16471649
'X-Parse-REST-API-Key': 'rest',
16481650
},
16491651
json: true,
1650-
}).then(body => {
1652+
}).then(response => {
1653+
const body = response.data;
16511654
expect(body.secretField).toEqual('SSID');
16521655
expect(hook.method).toHaveBeenCalled();
16531656
done();

0 commit comments

Comments
 (0)