Compare commits

...

2 commits

Author SHA1 Message Date
a7250ef323 add http-server part 6.1
All checks were successful
ci / build (push) Successful in 1m5s
2025-04-10 10:21:29 +02:00
c8d6cc124d add http-server part 6 2025-04-10 08:57:08 +02:00
10 changed files with 52 additions and 21 deletions

View file

@ -9,7 +9,10 @@ COPY . .
RUN npm install -g npm@11.2.0
RUN npm install
RUN npx tsc -p tsconfig.json
#RUN npx tsc -p tsconfig.json
RUN npx tsc -p tsconfig.backend.json
RUN npx tsc -p tsconfig.frontend.json
# 2. Rust build-Stage
FROM forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/rust:1.74.0 AS rust-build
@ -21,11 +24,22 @@ FROM forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/node:20.18.1
WORKDIR /app
COPY --from=build /app/dist ./dist
#COPY --from=build /app/index.html ./dist/iching/
COPY --from=build /app/index.html ./dist/
#COPY --from=build /app/index.html ./dist/
COPY --from=build /app/frontend/index.html ./dist/frontend/
COPY --from=rust-build /usr/local/cargo/bin/iching /usr/local/bin/iching
RUN mkdir -p dist/iching
RUN cp dist/*.js dist/iching/
CMD ["npx", "http-server", "dist", "-p", "8080", "--mime", "application/javascript=js"]
### NEW ###
RUN find dist/backend -name "*.js" -exec bash -c 'mv "$0" "${0%.js}.mjs"' {} \;
RUN find dist/frontend -name "*.js" -exec bash -c 'mv "$0" "${0%.js}.cjs"' {} \;
RUN mkdir -p dist/iching
#RUN cp dist/*.js dist/iching/
#RUN node dist/iching/server.js
RUN node dist/backend/server.mjs &
#CMD ["npx", "http-server", "dist", "-p", "8080", "--mime", "application/javascript=js"]
CMD ["npx", "http-server", "dist/frontend", "-p", "8080", "--mime", "application/javascript=js"]

View file

@ -1,4 +1,4 @@
import { html } from "./broker";
/*import { html } from "./broker";
import { test, beforeAll, afterAll } from "@jest/globals";
jest.useFakeTimers();
@ -17,3 +17,4 @@ test("Generate HTML for images", () => {
expect(html("Images:\nOver the earth, the lake:\nThe image of Gathering Together.\nThus the superior man renews his weapons\nIn order to meet the unforseen."))
.toBe("<p><h3>Images:</h3>Over the earth, the lake:<br>The image of Gathering Together.<br>Thus the superior man renews his weapons<br>In order to meet the unforseen.<br></p></div>");
});
*/

View file

@ -12,4 +12,4 @@ app.post('/api/command', (req, res) => {
app.listen(port, '0.0.0.0', () => {
console.log(`Server läuft auf http://0.0.0.0:${port}`);
});
});

View file

@ -3,12 +3,13 @@ function handleClick(): void {
console.log("Der Button wurde geklickt!");
alert("Hallo von TypeScript!");
/*fetch("/api/command", { method: "POST" })
fetch("/api/command", { method: "POST" })
.then(res => res.text())
.then(text => console.log("Server sagt:", text));*/
fetch("https://192-168-197-2.c-one-infra.de/api/command", { method: "POST" })
.then(text => console.log("Server sagt:", text));
/*fetch("https://192-168-197-2.c-one-infra.de/api/command", { method: "POST" })
.then(res => res.text())
.then(text => console.log("Server sagt:", text));
.then(text => console.log("Server sagt:", text)); */
}
document.addEventListener("DOMContentLoaded", () => {

View file

@ -8,7 +8,7 @@
"keywords": [],
"author": "",
"license": "ISC",
"type": "commonjs",
"type": "module",
"description": "",
"devDependencies": {
"@types/express": "^5.0.1",

8
tsconfig.backend.json Normal file
View file

@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist/backend",
"module": "ESNext"
},
"include": ["backend/**/*.ts"]
}

8
tsconfig.frontend.json Normal file
View file

@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist/frontend",
"module": "CommonJS"
},
"include": ["frontend/**/*.ts"]
}

View file

@ -1,10 +1,9 @@
{
"compilerOptions": {
"target": "ES6",
"module": "ES6",
"moduleResolution": "Node",
"outDir": "dist",
"strict": true,
"esModuleInterop": true
}
"compilerOptions": {
"target": "es2020",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}