Skip to content

Commit c478690

Browse files
committed
update dependencies and lint code
1 parent 950d024 commit c478690

30 files changed

+4130
-4019
lines changed

.eslintrc.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@
3535
"WithStatement"
3636
],
3737
// disable import/extensions rule as node requires to specify the extension on es module imports
38-
"import/extensions": "off"
38+
"import/extensions": "off",
39+
// allow implicit undefined return
40+
"consistent-return": "off",
41+
// not a problem in esm
42+
"no-param-reassign": "off"
3943
},
4044
"overrides": [
4145
{

bin/performance.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,25 @@ Script to monitor the I/O speed of an Application.
44
The output will be written in ../perf.csv
55
*/
66

7-
const axios = require('axios');
8-
const { performance } = require('perf_hooks');
97
const fs = require('fs');
8+
const { performance } = require('perf_hooks');
9+
10+
const axios = require('axios');
1011
const json2csv = require('json2csv');
1112

1213
// To be changed with the Application to Monitor
1314
const APP_NAME = '7n3k8m-Test';
1415
const APP_TOKEN = 'f81eda23-3bab-466e-89bb-627a96ba3991';
1516

16-
const getHeaderWithToken = function (sessionToken) {
17+
const getHeaderWithToken = function getHeaderWithToken (sessionToken) {
1718
return {
1819
'x-parse-application-id': 'connect',
1920
'x-parse-session-token': sessionToken,
2021
'content-type': 'application/json',
2122
};
2223
};
2324

24-
const writeToCSV = function (task, quantity, time) {
25+
const writeToCSV = function writeToCSV (task, quantity, time) {
2526
const newLine = '\r\n';
2627
const fields = ['date', 'task', 'quantity', 'time'];
2728
const data = {
@@ -52,7 +53,7 @@ const writeToCSV = function (task, quantity, time) {
5253
});
5354
};
5455

55-
const createObjects = async function (numberOfObject, sessionToken) {
56+
const createObjects = async function createObjects (numberOfObject, sessionToken) {
5657
const t0 = performance.now();
5758
for (let i = 0; i < numberOfObject; i++) {
5859
// eslint-disable-next-line no-await-in-loop
@@ -75,7 +76,7 @@ const createObjects = async function (numberOfObject, sessionToken) {
7576
writeToCSV('POST /classes', numberOfObject, t1 - t0);
7677
};
7778

78-
const readObjects = async function (numberOfObject, sessionToken) {
79+
const readObjects = async function readObjects (numberOfObject, sessionToken) {
7980
const t0 = performance.now();
8081
// eslint-disable-next-line no-unused-vars
8182
for (const _ of Array(numberOfObject).keys()) {
@@ -91,7 +92,7 @@ const readObjects = async function (numberOfObject, sessionToken) {
9192
writeToCSV('GET /classes', numberOfObject, t1 - t0);
9293
};
9394

94-
const readObjectsWithCondition = async function (numberOfObject, sessionToken) {
95+
const readObjectsWithCondition = async function readObjectsWithCondition (numberOfObject, sessionToken) {
9596
const t0 = performance.now();
9697
for (let i = 0; i < numberOfObject; i++) {
9798
// eslint-disable-next-line no-await-in-loop
@@ -112,7 +113,7 @@ const readObjectsWithCondition = async function (numberOfObject, sessionToken) {
112113
writeToCSV('GET /classes w/ condition', numberOfObject, t1 - t0);
113114
};
114115

115-
const checkAdd = async function () {
116+
const checkAdd = async function checkAdd () {
116117
try {
117118
const response = await axios.get('http://127.0.0.1:1337/parse/login', {
118119
params: {

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@
6565
"react-dom": "^18.2.0",
6666
"react-moment": "^1.1.3",
6767
"react-router-dom": "6.14.1",
68-
"request": "^2.88.2",
69-
"request-promise": "^4.2.6",
7068
"swagger-ui-express": "^4.6.2",
7169
"uuid": "^9.0.0",
7270
"validate.js": "^0.13.1",
@@ -95,7 +93,7 @@
9593
"husky": "^8.0.3",
9694
"jest": "^29.5.0",
9795
"json2csv": "^6.0.0-alpha.2",
98-
"lint-staged": ">=13.2.0",
96+
"lint-staged": "^14",
9997
"mini-css-extract-plugin": "^2.7.5",
10098
"mongodb": "^5.1.0",
10199
"nock": "^13.3.0",

spec/api.spec.js

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
/* eslint-disable max-lines */
22
/* eslint-disable max-statements */
3-
import Parse from 'parse/node';
43
import axios from 'axios';
4+
import Parse from 'parse/node';
55
import qs from 'qs';
6-
import { bindAll } from './helper';
6+
77
import config from './__mock__/config';
8+
import { bindAll } from './helper';
89

910
const { API_URL, PARSE_APP_ID } = config;
1011

@@ -180,7 +181,7 @@ describe('Parse server', () => {
180181

181182
// simulate confirmation by the app's backend
182183
const { data } = await axios.post(
183-
API_URL + '/oauth/token',
184+
`${API_URL }/oauth/token`,
184185
qs.stringify({
185186
client_id: fromApp.publicKey,
186187
client_secret: fromApp.secretKey,
@@ -228,15 +229,15 @@ describe('Parse server', () => {
228229
});
229230

230231
it('GET the user id associated to the accessToken', async () => {
231-
const { data } = await axios.get(API_URL + '/oauth/user', {
232-
headers: { Authorization: 'Bearer ' + accessToken.access_token },
232+
const { data } = await axios.get(`${API_URL }/oauth/user`, {
233+
headers: { Authorization: `Bearer ${ accessToken.access_token}` },
233234
});
234235
expect(data.id).toBe(endUserUserId);
235236
});
236237

237238
it('GET valid OAuth refreshToken', async () => {
238239
const { data } = await axios.post(
239-
API_URL + '/oauth/token',
240+
`${API_URL }/oauth/token`,
240241
qs.stringify({
241242
client_id: application.publicKey,
242243
client_secret: application.secretKey,
@@ -294,8 +295,8 @@ describe('Parse server', () => {
294295
application2,
295296
);
296297

297-
const { data } = await axios.get(API_URL + '/oauth/user', {
298-
headers: { Authorization: 'Bearer ' + token },
298+
const { data } = await axios.get(`${API_URL }/oauth/user`, {
299+
headers: { Authorization: `Bearer ${ token}` },
299300
});
300301
expect(data.id).toBe(endUserUserId);
301302
});
@@ -310,7 +311,7 @@ describe('Parse server', () => {
310311
headers: {
311312
'Content-Type': 'application/json',
312313
'x-parse-application-id': PARSE_APP_ID,
313-
Authorization: 'Bearer ' + accessToken.access_token,
314+
Authorization: `Bearer ${ accessToken.access_token}`,
314315
},
315316
data: { score: 1337, playerName: 'test9', cheatMode: false },
316317
});
@@ -341,7 +342,7 @@ describe('Parse server', () => {
341342
headers: {
342343
'Content-Type': 'application/json',
343344
'x-parse-application-id': PARSE_APP_ID,
344-
Authorization: 'Bearer ' + accessToken.access_token,
345+
Authorization: `Bearer ${ accessToken.access_token}`,
345346
},
346347
data: {
347348
requests: [
@@ -371,7 +372,7 @@ describe('Parse server', () => {
371372
headers: {
372373
'Content-Type': 'application/json',
373374
'x-parse-application-id': PARSE_APP_ID,
374-
Authorization: 'Bearer ' + accessToken.access_token,
375+
Authorization: `Bearer ${ accessToken.access_token}`,
375376
},
376377
});
377378
expect(data).toEqual(gameScoreObject);
@@ -384,7 +385,7 @@ describe('Parse server', () => {
384385
headers: {
385386
'Content-Type': 'application/json',
386387
'x-parse-application-id': PARSE_APP_ID,
387-
Authorization: 'Bearer ' + accessToken.access_token,
388+
Authorization: `Bearer ${ accessToken.access_token}`,
388389
},
389390
});
390391

@@ -398,7 +399,7 @@ describe('Parse server', () => {
398399
headers: {
399400
'Content-Type': 'application/json',
400401
'x-parse-application-id': PARSE_APP_ID,
401-
Authorization: 'Bearer ' + accessToken.access_token,
402+
Authorization: `Bearer ${ accessToken.access_token}`,
402403
},
403404
data: {
404405
count: 1,
@@ -472,7 +473,7 @@ describe('Parse server', () => {
472473
headers: {
473474
'Content-Type': 'application/json',
474475
'x-parse-application-id': PARSE_APP_ID,
475-
Authorization: 'Bearer ' + accessToken.access_token,
476+
Authorization: `Bearer ${ accessToken.access_token}`,
476477
},
477478
data: {
478479
requests: requestArray,
@@ -492,7 +493,7 @@ describe('Parse server', () => {
492493
headers: {
493494
'Content-Type': 'application/json',
494495
'x-parse-application-id': PARSE_APP_ID,
495-
Authorization: 'Bearer ' + accessToken.access_token,
496+
Authorization: `Bearer ${ accessToken.access_token}`,
496497
'x-is-sandbox': true
497498
},
498499
data: { score: 1339, playerName: 'test0', cheatMode: true },
@@ -524,7 +525,7 @@ describe('Parse server', () => {
524525
headers: {
525526
'Content-Type': 'application/json',
526527
'x-parse-application-id': PARSE_APP_ID,
527-
Authorization: 'Bearer ' + accessToken.access_token,
528+
Authorization: `Bearer ${ accessToken.access_token}`,
528529
'x-is-sandbox': true
529530
},
530531
data: {
@@ -561,7 +562,7 @@ describe('Parse server', () => {
561562
headers: {
562563
'Content-Type': 'application/json',
563564
'x-parse-application-id': PARSE_APP_ID,
564-
Authorization: 'Bearer ' + accessToken.access_token,
565+
Authorization: `Bearer ${ accessToken.access_token}`,
565566
'x-is-sandbox': true
566567
},
567568
});
@@ -575,7 +576,7 @@ describe('Parse server', () => {
575576
headers: {
576577
'Content-Type': 'application/json',
577578
'x-parse-application-id': PARSE_APP_ID,
578-
Authorization: 'Bearer ' + accessToken.access_token,
579+
Authorization: `Bearer ${ accessToken.access_token}`,
579580
'x-is-sandbox': true
580581
},
581582
});
@@ -607,7 +608,7 @@ describe('Parse server', () => {
607608
headers: {
608609
'Content-Type': 'application/json',
609610
'x-parse-application-id': PARSE_APP_ID,
610-
Authorization: 'Bearer ' + accessToken.access_token
611+
Authorization: `Bearer ${ accessToken.access_token}`
611612
},
612613
});
613614
} catch (err) {
@@ -626,7 +627,7 @@ describe('Parse server', () => {
626627
headers: {
627628
'Content-Type': 'application/json',
628629
'x-parse-application-id': PARSE_APP_ID,
629-
Authorization: 'Bearer ' + accessToken.access_token,
630+
Authorization: `Bearer ${ accessToken.access_token}`,
630631
'x-is-sandbox': true
631632
},
632633
});
@@ -644,7 +645,7 @@ describe('Parse server', () => {
644645
headers: {
645646
'Content-Type': 'application/json',
646647
'x-parse-application-id': PARSE_APP_ID,
647-
Authorization: 'Bearer ' + accessToken.access_token,
648+
Authorization: `Bearer ${ accessToken.access_token}`,
648649
'x-is-sandbox': true
649650
},
650651
});
@@ -659,7 +660,7 @@ describe('Parse server', () => {
659660
headers: {
660661
'Content-Type': 'application/json',
661662
'x-parse-application-id': PARSE_APP_ID,
662-
Authorization: 'Bearer ' + accessToken.access_token,
663+
Authorization: `Bearer ${ accessToken.access_token}`,
663664
},
664665
data: { score: 1338, cheatMode: true },
665666
});
@@ -690,7 +691,7 @@ describe('Parse server', () => {
690691
headers: {
691692
'Content-Type': 'application/json',
692693
'x-parse-application-id': PARSE_APP_ID,
693-
Authorization: 'Bearer ' + accessTokenApp2.access_token,
694+
Authorization: `Bearer ${ accessTokenApp2.access_token}`,
694695
},
695696
data: { score: 1338, cheatMode: true },
696697
});
@@ -815,7 +816,7 @@ describe('Parse server', () => {
815816
headers: {
816817
'Content-Type': 'application/json',
817818
'x-parse-application-id': PARSE_APP_ID,
818-
Authorization: 'Bearer ' + accessTokenApp2.access_token,
819+
Authorization: `Bearer ${ accessTokenApp2.access_token}`,
819820
}
820821
});
821822
} catch (err) {
@@ -830,7 +831,7 @@ describe('Parse server', () => {
830831
headers: {
831832
'Content-Type': 'application/json',
832833
'x-parse-application-id': PARSE_APP_ID,
833-
Authorization: 'Bearer ' + accessToken.access_token,
834+
Authorization: `Bearer ${ accessToken.access_token}`,
834835
},
835836
});
836837

spec/helper.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import mongoose from 'mongoose';
2-
import nock from 'nock';
31
import { EventEmitter, once } from 'events';
2+
43
// eslint-disable-next-line import/no-extraneous-dependencies
54
import { jest } from '@jest/globals';
5+
import mongoose from 'mongoose';
6+
import nock from 'nock';
7+
// eslint-disable-next-line import/no-extraneous-dependencies
68

79
import configMock from './__mock__/config';
810

@@ -13,7 +15,7 @@ jest.unstable_mockModule('../src/config', () => configMock);
1315
// Set up a default API server for testing with default configuration.
1416
const ConnectServer = (await import('../src/connectServer')).default;
1517

16-
const bindServer = function () {
18+
const bindServer = function bindServer () {
1719
let server;
1820

1921
afterAll(async () => {
@@ -34,7 +36,7 @@ const bindServer = function () {
3436
});
3537
};
3638

37-
const bindGithub = function () {
39+
const bindGithub = function bindGithub () {
3840
beforeAll(() => {
3941
nock(`https://github.com`)
4042
.persist()
@@ -54,7 +56,7 @@ const bindGithub = function () {
5456
afterAll(() => nock.cleanAll());
5557
};
5658

57-
const bindAll = function () {
59+
const bindAll = function bindAll () {
5860
bindServer();
5961
bindGithub();
6062
};

src/config/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'dotenv/config';
22

3-
const testConfig = function (config, name) {
3+
const testConfig = function testConfig (config, name) {
44
if (
55
(!config && config !== false && config !== 'false') ||
66
`${config}`.length <= 0

src/connectServer.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
import express from 'express';
2-
import bodyParser from 'body-parser';
3-
import bodyParserErrorHandler from 'express-body-parser-error-handler';
41
import path from 'path';
5-
import cors from 'cors';
62
import { fileURLToPath } from 'url';
73

4+
import bodyParser from 'body-parser';
5+
import cors from 'cors';
6+
import express from 'express';
7+
import bodyParserErrorHandler from 'express-body-parser-error-handler';
8+
89
import logger from './logger.js';
9-
import oauthApi from './oauth/oauth-routes.js';
1010
import parseApi from './middleware/parse.js';
1111
import parseDashboard from './middleware/parseDashboard.js';
1212
import parseSwagger from './middleware/parseSwagger.js';
1313
import sandboxMiddleware from './middleware/sandboxMiddleware.js';
1414
import oauthMiddleware from './oauth/oauth-middleware.js';
15+
import oauthApi from './oauth/oauth-routes.js';
1516

1617
// eslint-disable-next-line max-statements
17-
const start = async function (port, parseCloudEvent) {
18+
const start = async function start (port, parseCloudEvent) {
1819
logger.info(`start connect express server on port ${port}.`);
1920

2021
process.on('unhandledRejection', (err) => {
21-
console.log(err);
22+
logger.error(err);
2223
throw err;
2324
});
2425

0 commit comments

Comments
 (0)