Skip to content

Commit

Permalink
Refactor e2e-test-server to use builtin serve-static from express rat…
Browse files Browse the repository at this point in the history
…her than importing it ourselves

- this means we can remove the serve-static dependency, and fixes a vulnerability alert
  • Loading branch information
louise-davies committed Feb 17, 2025
1 parent b54c451 commit f27e59e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 42 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
"lint-staged": "15.4.3",
"prettier": "3.5.0",
"serve": "14.2.0",
"serve-static": "1.16.0",
"start-server-and-test": "2.0.10",
"typescript-eslint": "8.24.0",
"vitest": "3.0.5",
Expand Down
13 changes: 6 additions & 7 deletions server/e2e-test-server.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import express from 'express';
import path from 'path';
import serveStatic from 'serve-static';

var app = express();
const app = express();

app.get('/operationsgateway-settings.json', function (req, res) {
app.get('/operationsgateway-settings.json', function (_req, res) {
// detect if the E2E test is running inside CI
// If so, use the settings file specific to E2E
// Otherwise, use the same settings file that is also for running the app normally (yarn start etc).
Expand All @@ -23,14 +22,14 @@ app.get('/operationsgateway-settings.json', function (req, res) {

app.use(
express.json(),
serveStatic(path.resolve('./dist'), { index: ['index.html', 'index.htm'] })
express.static(path.resolve('./dist'), { index: ['index.html', 'index.htm'] })
);

app.get('/*', function (req, res) {
app.get('/*', function (_req, res) {
res.sendFile(path.resolve('./dist/index.html'));
});

var server = app.listen(3000, '0.0.0.0', function () {
var port = server.address().port;
const server = app.listen(3000, '0.0.0.0', function () {
const port = server.address().port;
console.log('E2E test server listening at http://localhost:%s', port);
});
34 changes: 0 additions & 34 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6863,7 +6863,6 @@ __metadata:
react-dom: "npm:18.3.1"
react-redux: "npm:9.2.0"
serve: "npm:14.2.0"
serve-static: "npm:1.16.0"
single-spa-react: "npm:6.0.2"
start-server-and-test: "npm:2.0.10"
typescript: "npm:5.6.2"
Expand Down Expand Up @@ -7917,27 +7916,6 @@ __metadata:
languageName: node
linkType: hard

"send@npm:0.18.0":
version: 0.18.0
resolution: "send@npm:0.18.0"
dependencies:
debug: "npm:2.6.9"
depd: "npm:2.0.0"
destroy: "npm:1.2.0"
encodeurl: "npm:~1.0.2"
escape-html: "npm:~1.0.3"
etag: "npm:~1.8.1"
fresh: "npm:0.5.2"
http-errors: "npm:2.0.0"
mime: "npm:1.6.0"
ms: "npm:2.1.3"
on-finished: "npm:2.4.1"
range-parser: "npm:~1.2.1"
statuses: "npm:2.0.1"
checksum: 10c0/0eb134d6a51fc13bbcb976a1f4214ea1e33f242fae046efc311e80aff66c7a43603e26a79d9d06670283a13000e51be6e0a2cb80ff0942eaf9f1cd30b7ae736a
languageName: node
linkType: hard

"send@npm:0.19.0":
version: 0.19.0
resolution: "send@npm:0.19.0"
Expand Down Expand Up @@ -7975,18 +7953,6 @@ __metadata:
languageName: node
linkType: hard

"serve-static@npm:1.16.0":
version: 1.16.0
resolution: "serve-static@npm:1.16.0"
dependencies:
encodeurl: "npm:~1.0.2"
escape-html: "npm:~1.0.3"
parseurl: "npm:~1.3.3"
send: "npm:0.18.0"
checksum: 10c0/d7a5beca08cc55f92998d8b87c111dd842d642404231c90c11f504f9650935da4599c13256747b0a988442a59851343271fe8e1946e03e92cd79c447b5f3ae01
languageName: node
linkType: hard

"serve-static@npm:1.16.2":
version: 1.16.2
resolution: "serve-static@npm:1.16.2"
Expand Down

0 comments on commit f27e59e

Please sign in to comment.