Skip to content

Commit

Permalink
chore: upgrade to express 5 (#4611)
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbo committed Nov 19, 2024
1 parent deedf28 commit dea74d2
Show file tree
Hide file tree
Showing 12 changed files with 299 additions and 172 deletions.
2 changes: 1 addition & 1 deletion api/bull-board/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ module.exports = {
rateSlowing: {
windowMs: 1 * 60 * 1000, // 1 minute window
delayAfter: 25, // delay requests by delayMs after 25 are made in a window
delayMs: 500, // delay requests by 500 ms
delayMs: () => 500, // delay requests by 500 ms
},
};
1 change: 0 additions & 1 deletion api/middlewares/parse-form.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const { urlencoded } = require('express');

const parseForm = urlencoded({
extended: false,
limit: '1kb',
});

Expand Down
6 changes: 1 addition & 5 deletions api/routers/build-log.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ const router = require('express').Router();
const BuildLogController = require('../controllers/build-log');
const { sessionAuth } = require('../middlewares');

router.get(
'/build/:build_id/log(/offset/:offset)?',
sessionAuth,
BuildLogController.find,
);
router.get('/build/:build_id/log{/offset/:offset}', sessionAuth, BuildLogController.find);

module.exports = router;
2 changes: 1 addition & 1 deletion api/routers/build-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ router.post(
router.put('/tasks/:build_task_id/:token', BuildTaskController.update);
router.get('/tasks/types', sessionAuth, BuildTaskTypeController.list);
router.get('/tasks/default-rules', sessionAuth, BuildTaskTypeController.getDefaultRules);
router.get('/tasks/:task_id/report/:sub_page?', sessionAuth, BuildTaskController.report);
router.get('/tasks/:task_id/report/{:sub_page}', sessionAuth, BuildTaskController.report);

module.exports = router;
6 changes: 3 additions & 3 deletions api/routers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ router.get('/', MainController.home);
router.get('/system-use', MainController.systemUse);

// add csrf middleware to app route so that we can use request.csrfToken()
router.get('/organizations(/*)?', csrfProtection, MainController.app);
router.get('/sites(/*)?', csrfProtection, MainController.app);
router.get('/organizations{/*splat}', csrfProtection, MainController.app);
router.get('/sites{/*splat}', csrfProtection, MainController.app);
router.get('/settings', csrfProtection, MainController.app);

router.get('/robots.txt', MainController.robots);

router.options('(/*)?', (_req, res) => res.notFound());
router.options('{/*splat}', (_req, res) => res.notFound());

module.exports = router;
2 changes: 1 addition & 1 deletion api/routers/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ const MainController = require('../controllers/main');
const { csrfProtection } = require('../middlewares');

// add csrf middleware to app route so that we can use request.csrfToken()
router.get('/report(/*)?', csrfProtection, MainController.report);
router.get('/report{*splat}', csrfProtection, MainController.report);

module.exports = router;
3 changes: 3 additions & 0 deletions config/env/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ module.exports = {
userEnvVar: {
key: 'shhhhhhhhhhh',
},
rateLimiting: {
skip: () => true,
}
};
8 changes: 8 additions & 0 deletions config/env/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,12 @@ module.exports = {
userEnvVar: {
key: 'shhhhhhhhhhh',
},
rateLimiting: {
skip: () => true,
},
rateSlowing: {
validate: {
delayMs: false
},
}
};
3 changes: 3 additions & 0 deletions config/rateLimiting.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
*/
module.exports = {
max: 0,
validate: {
trustProxy: false
},
};
2 changes: 1 addition & 1 deletion config/rateSlowing.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
*/
module.exports = {
delayAfter: 0,
delayMs: 0,
delayMs: () => 0,
};
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"db-migrate-pg": "^1.5.2",
"deep-extend": "^0.6",
"eslint-plugin-react-hooks": "^4.6.0",
"express": "^4.19.2",
"express-rate-limit": "^5.2.3",
"express-session": "^1.18.0",
"express-slow-down": "^1.4.0",
"express-winston": "^4.0.5",
"express": "^5.0.1",
"express-rate-limit": "^7.4.1",
"express-session": "^1.18.1",
"express-slow-down": "^2.0.3",
"express-winston": "^4.2.0",
"globals": "^15.12.0",
"helmet": "^4.6.0",
"inflection": "^1.13.1",
Expand Down Expand Up @@ -162,7 +162,7 @@
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-sonarjs": "^2.0.4",
"eslint-plugin-testing-library": "^6.4.0",
"fetch-mock": "^9.11.0",
"fetch-mock": "^12.1.0",
"jest": "^29.6.2",
"jest-environment-jsdom": "^29.6.2",
"jsdom": "^23.0.1",
Expand All @@ -177,7 +177,6 @@
"nodemon": "^3.0.1",
"nyc": "^15.1.0",
"playwright": "^1.42.1",
"plugin": "^0.3.3",
"postcss": "^8.4.31",
"postcss-loader": "^7.3.3",
"prettier": "^3.3.3",
Expand Down
Loading

0 comments on commit dea74d2

Please sign in to comment.