Skip to content

Commit

Permalink
[frontend] Fix deprecated start method to start frontend (#1678)
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumejparis authored Oct 18, 2024
1 parent 10f2d52 commit c377ffa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 63 deletions.
27 changes: 13 additions & 14 deletions openbas-front/builder/dev/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import fsExtra from "fs-extra/esm";
import path from "node:path";
import esbuild from "esbuild";
import chokidar from "chokidar";
import compression from "compression";

// mimic CommonJS variables -- not needed if using CommonJS
const __filename = fileURLToPath(import.meta.url);
Expand All @@ -24,9 +23,10 @@ const debounce = (func, timeout = 500) => {
}, timeout);
};
};

const middleware = (target, ws = true) =>
createProxyMiddleware(basePath + target, {
target: "http://localhost:8080",
createProxyMiddleware({
target: "http://localhost:8080" + basePath + target,
changeOrigin: true,
ws,
});
Expand All @@ -39,7 +39,7 @@ esbuild
publicPath: "/",
bundle: true,
banner: {
js: ' (() => new EventSource("http://localhost:3000/dev").onmessage = () => location.reload())();',
js: ' (() => new EventSource("http://localhost:3001/dev").onmessage = () => location.reload())();',
},
loader: {
".js": "jsx",
Expand Down Expand Up @@ -67,9 +67,9 @@ esbuild
});
// Listen change for hot recompile
chokidar
.watch("src/**/*.{js,jsx,ts,tsx}", {
awaitWriteFinish: true,
ignoreInitial: true,
.watch('./src', {
ignored: (path, stats) => stats?.isFile()
&& !(path.endsWith('.js') || path.endsWith('.jsx') || path.endsWith('.ts') || path.endsWith('.tsx')),
})
.on(
"all",
Expand Down Expand Up @@ -104,12 +104,11 @@ esbuild
);
});
app.set("trust proxy", 1);
app.use(compression({}));
app.use(middleware("/api"));
app.use(middleware("/login"));
app.use(middleware("/logout"));
app.use(middleware("/oauth2"));
app.use(middleware("/saml2"));
app.use("/api", middleware("/api"));
app.use("/login", middleware("/login"));
app.use("/logout", middleware("/logout"));
app.use("/oauth2", middleware("/oauth2"));
app.use("/saml2", middleware("/saml2"));
app.use(
basePath + `/static`,
express.static(path.join(__dirname, "./build/static")),
Expand All @@ -132,5 +131,5 @@ esbuild
res.header("Pragma", "no-cache");
return res.send(withOptionValued);
});
app.listen(3000);
app.listen(3001);
});
1 change: 0 additions & 1 deletion openbas-front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
"@typescript-eslint/parser": "7.18.0",
"@vitejs/plugin-react": "4.3.0",
"chokidar": "4.0.1",
"compression": "1.7.4",
"cross-env": "7.0.3",
"esbuild": "0.24.0",
"eslint": "8.57.1",
Expand Down
50 changes: 2 additions & 48 deletions openbas-front/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5450,7 +5450,7 @@ __metadata:
languageName: node
linkType: hard

"accepts@npm:~1.3.5, accepts@npm:~1.3.8":
"accepts@npm:~1.3.8":
version: 1.3.8
resolution: "accepts@npm:1.3.8"
dependencies:
Expand Down Expand Up @@ -6045,13 +6045,6 @@ __metadata:
languageName: node
linkType: hard

"bytes@npm:3.0.0":
version: 3.0.0
resolution: "bytes@npm:3.0.0"
checksum: 10c0/91d42c38601c76460519ffef88371caacaea483a354c8e4b8808e7b027574436a5713337c003ea3de63ee4991c2a9a637884fdfe7f761760d746929d9e8fec60
languageName: node
linkType: hard

"bytes@npm:3.1.2":
version: 3.1.2
resolution: "bytes@npm:3.1.2"
Expand Down Expand Up @@ -6593,30 +6586,6 @@ __metadata:
languageName: node
linkType: hard

"compressible@npm:~2.0.16":
version: 2.0.18
resolution: "compressible@npm:2.0.18"
dependencies:
mime-db: "npm:>= 1.43.0 < 2"
checksum: 10c0/8a03712bc9f5b9fe530cc5a79e164e665550d5171a64575d7dcf3e0395d7b4afa2d79ab176c61b5b596e28228b350dd07c1a2a6ead12fd81d1b6cd632af2fef7
languageName: node
linkType: hard

"compression@npm:1.7.4":
version: 1.7.4
resolution: "compression@npm:1.7.4"
dependencies:
accepts: "npm:~1.3.5"
bytes: "npm:3.0.0"
compressible: "npm:~2.0.16"
debug: "npm:2.6.9"
on-headers: "npm:~1.0.2"
safe-buffer: "npm:5.1.2"
vary: "npm:~1.1.2"
checksum: 10c0/138db836202a406d8a14156a5564fb1700632a76b6e7d1546939472895a5304f2b23c80d7a22bf44c767e87a26e070dbc342ea63bb45ee9c863354fa5556bbbc
languageName: node
linkType: hard

"concat-map@npm:0.0.1":
version: 0.0.1
resolution: "concat-map@npm:0.0.1"
Expand Down Expand Up @@ -11525,7 +11494,7 @@ __metadata:
languageName: node
linkType: hard

"mime-db@npm:1.52.0, mime-db@npm:>= 1.43.0 < 2":
"mime-db@npm:1.52.0":
version: 1.52.0
resolution: "mime-db@npm:1.52.0"
checksum: 10c0/0557a01deebf45ac5f5777fe7740b2a5c309c6d62d40ceab4e23da9f821899ce7a900b7ac8157d4548ddbb7beffe9abc621250e6d182b0397ec7f10c7b91a5aa
Expand Down Expand Up @@ -12086,13 +12055,6 @@ __metadata:
languageName: node
linkType: hard

"on-headers@npm:~1.0.2":
version: 1.0.2
resolution: "on-headers@npm:1.0.2"
checksum: 10c0/f649e65c197bf31505a4c0444875db0258e198292f34b884d73c2f751e91792ef96bb5cf89aa0f4fecc2e4dc662461dda606b1274b0e564f539cae5d2f5fc32f
languageName: node
linkType: hard

"once@npm:^1.3.0":
version: 1.4.0
resolution: "once@npm:1.4.0"
Expand Down Expand Up @@ -12157,7 +12119,6 @@ __metadata:
ckeditor5-custom-build: "link:packages/ckeditor5-custom-build"
classcat: "npm:^5.0.5"
classnames: "npm:2.5.1"
compression: "npm:1.7.4"
cronstrue: "npm:2.50.0"
cross-env: "npm:7.0.3"
d3-hierarchy: "npm:3.1.2"
Expand Down Expand Up @@ -14173,13 +14134,6 @@ __metadata:
languageName: node
linkType: hard

"safe-buffer@npm:5.1.2":
version: 5.1.2
resolution: "safe-buffer@npm:5.1.2"
checksum: 10c0/780ba6b5d99cc9a40f7b951d47152297d0e260f0df01472a1b99d4889679a4b94a13d644f7dbc4f022572f09ae9005fa2fbb93bbbd83643316f365a3e9a45b21
languageName: node
linkType: hard

"safe-buffer@npm:5.2.1, safe-buffer@npm:^5.1.0, safe-buffer@npm:~5.2.0":
version: 5.2.1
resolution: "safe-buffer@npm:5.2.1"
Expand Down

0 comments on commit c377ffa

Please sign in to comment.