Skip to content

Commit f49e9a7

Browse files
committed
upgraded to express 5 with tests passing
1 parent a579eeb commit f49e9a7

26 files changed

+970
-278
lines changed

package-lock.json

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

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@
2727
"@parse/fs-files-adapter": "3.0.0",
2828
"@parse/push-adapter": "6.8.0",
2929
"bcryptjs": "2.4.3",
30-
"body-parser": "1.20.3",
3130
"commander": "12.1.0",
3231
"cors": "2.8.5",
3332
"deepcopy": "2.1.0",
34-
"express": "4.21.2",
33+
"express": "5.0.1",
3534
"express-rate-limit": "7.4.1",
3635
"follow-redirects": "1.15.9",
3736
"graphql": "16.9.0",
@@ -57,6 +56,7 @@
5756
"punycode": "2.3.1",
5857
"rate-limit-redis": "4.2.0",
5958
"redis": "4.7.0",
59+
"router": "2.0.0",
6060
"semver": "7.6.3",
6161
"subscriptions-transport-ws": "0.11.0",
6262
"tv4": "1.3.0",
@@ -128,11 +128,11 @@
128128
"test:mongodb:7.0.1": "npm run test:mongodb --dbversion=7.0.1",
129129
"test:mongodb:8.0.3": "npm run test:mongodb --dbversion=8.0.3",
130130
"test:postgres:testonly": "cross-env PARSE_SERVER_TEST_DB=postgres PARSE_SERVER_TEST_DATABASE_URI=postgres://postgres:password@localhost:5432/parse_server_postgres_adapter_test_database npm run testonly",
131-
"pretest": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=5.3.2} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} mongodb-runner start -t ${MONGODB_TOPOLOGY} --version ${MONGODB_VERSION} -- --port 27017",
132-
"testonly": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=5.3.2} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} TESTING=1 jasmine",
131+
"pretest": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=6.0.2} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} mongodb-runner start -t ${MONGODB_TOPOLOGY} --version ${MONGODB_VERSION} -- --port 27017",
132+
"testonly": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=6.0.2} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} TESTING=1 jasmine",
133133
"test": "npm run testonly",
134-
"posttest": "cross-env mongodb-runner stop --all",
135-
"coverage": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=5.3.2} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} TESTING=1 nyc jasmine",
134+
"posttest": "cross-env mongodb-runner stop --all --debug",
135+
"coverage": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=6.0.2} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} TESTING=1 nyc jasmine",
136136
"start": "node ./bin/parse-server",
137137
"prettier": "prettier --write {src,spec}/{**/*,*}.js",
138138
"prepare": "npm run build",

spec/HTTPRequest.spec.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
const httpRequest = require('../lib/request'),
44
HTTPResponse = require('../lib/request').HTTPResponse,
5-
bodyParser = require('body-parser'),
65
express = require('express');
76

87
const port = 13371;
98
const httpRequestServer = `http://localhost:${port}`;
109

1110
function startServer(done) {
1211
const app = express();
13-
app.use(bodyParser.json({ type: '*/*' }));
12+
app.use(express.json({ type: '*/*' }));
1413
app.get('/hello', function (req, res) {
1514
res.json({ response: 'OK' });
1615
});

spec/ParseHooks.spec.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const request = require('../lib/request');
44
const triggers = require('../lib/triggers');
55
const HooksController = require('../lib/Controllers/HooksController').default;
66
const express = require('express');
7-
const bodyParser = require('body-parser');
87
const auth = require('../lib/Auth');
98
const Config = require('../lib/Config');
109

@@ -17,7 +16,7 @@ describe('Hooks', () => {
1716
beforeEach(done => {
1817
if (!app) {
1918
app = express();
20-
app.use(bodyParser.json({ type: '*/*' }));
19+
app.use(express.json({ type: '*/*' }));
2120
server = app.listen(port, undefined, done);
2221
} else {
2322
done();

spec/vulnerabilities.spec.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,10 @@ describe('Vulnerabilities', () => {
250250

251251
it_id('e8b5f1e1-8326-4c70-b5f4-1e8678dfff8d')(it)('denies creating a hook with polluted data', async () => {
252252
const express = require('express');
253-
const bodyParser = require('body-parser');
254253
const port = 34567;
255254
const hookServerURL = 'http://localhost:' + port;
256255
const app = express();
257-
app.use(bodyParser.json({ type: '*/*' }));
256+
app.use(express.json({ type: '*/*' }));
258257
const server = await new Promise(resolve => {
259258
const res = app.listen(port, undefined, () => resolve(res));
260259
});

src/Controllers/AnalyticsController.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export class AnalyticsController extends AdaptableController {
55
appOpened(req) {
66
return Promise.resolve()
77
.then(() => {
8-
return this.adapter.appOpened(req.body, req);
8+
return this.adapter.appOpened(req.body || {}, req);
99
})
1010
.then(response => {
1111
return { response: response || {} };
@@ -18,7 +18,7 @@ export class AnalyticsController extends AdaptableController {
1818
trackEvent(req) {
1919
return Promise.resolve()
2020
.then(() => {
21-
return this.adapter.trackEvent(req.params.eventName, req.body, req);
21+
return this.adapter.trackEvent(req.params.eventName, req.body || {}, req);
2222
})
2323
.then(response => {
2424
return { response: response || {} };

src/ParseServer.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// ParseServer - open-source compatible API Server for Parse apps
22

33
var batch = require('./batch'),
4-
bodyParser = require('body-parser'),
54
express = require('express'),
65
middlewares = require('./middlewares'),
76
Parse = require('parse/node').Parse,
@@ -272,13 +271,13 @@ class ParseServer {
272271

273272
api.use(
274273
'/',
275-
bodyParser.urlencoded({ extended: false }),
274+
express.urlencoded({ extended: false }),
276275
pages.enableRouter
277276
? new PagesRouter(pages).expressRouter()
278277
: new PublicAPIRouter().expressRouter()
279278
);
280279

281-
api.use(bodyParser.json({ type: '*/*', limit: maxUploadSize }));
280+
api.use(express.json({ type: '*/*', limit: maxUploadSize }));
282281
api.use(middlewares.allowMethodOverride);
283282
api.use(middlewares.handleParseHeaders);
284283
const routes = Array.isArray(rateLimit) ? rateLimit : [rateLimit];

src/PromiseRouter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Parse from 'parse/node';
99
import express from 'express';
1010
import log from './logger';
1111
import { inspect } from 'util';
12-
const Layer = require('express/lib/router/layer');
12+
const Layer = require('router/lib/layer');
1313

1414
function validateParameter(key, value) {
1515
if (key == 'className') {

src/Routers/AggregateRouter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import UsersRouter from './UsersRouter';
66

77
export class AggregateRouter extends ClassesRouter {
88
handleFind(req) {
9-
const body = Object.assign(req.body, ClassesRouter.JSONFromQuery(req.query));
9+
const body = Object.assign(req.body || {}, ClassesRouter.JSONFromQuery(req.query));
1010
const options = {};
1111
if (body.distinct) {
1212
options.distinct = String(body.distinct);

src/Routers/AudiencesRouter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export class AudiencesRouter extends ClassesRouter {
88
}
99

1010
handleFind(req) {
11-
const body = Object.assign(req.body, ClassesRouter.JSONFromQuery(req.query));
11+
const body = Object.assign(req.body || {}, ClassesRouter.JSONFromQuery(req.query));
1212
const options = ClassesRouter.optionsFromBody(body, req.config.defaultLimit);
1313

1414
return rest

0 commit comments

Comments
 (0)