Skip to content

Commit 4b90256

Browse files
committed
add websocket protocol in Configuration.js
1 parent eb18c82 commit 4b90256

File tree

6 files changed

+19
-6
lines changed

6 files changed

+19
-6
lines changed

dev.env

+2
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ BASE_URL_DOMAIN="localhost"
33
BASE_URL_PORT=7001
44
BASE_URL_PATH="/"
55

6+
WEBSOCKET_PROTOCOL="ws"
7+
68
DB_PASSWORD="password"

docker-compose.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ services:
3838
BASE_URL_DOMAIN: $BASE_URL_DOMAIN
3939
BASE_URL_PORT: $BASE_URL_PORT
4040
BASE_URL_PATH: $BASE_URL_PATH
41+
WEBSOCKET_PROTOCOL: $WEBSOCKET_PROTOCOL
4142
dockerfile: ./microservices/playground-ws/Dockerfile
4243
ports:
4344
- "7001:7001"

microservices/playground-ws/Dockerfile

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ ARG BASE_URL_PROTOCOL
77
ARG BASE_URL_DOMAIN
88
ARG BASE_URL_PORT
99
ARG BASE_URL_PATH
10+
ARG $WEBSOCKET_PROTOCOL
1011

1112
RUN echo "BASE_URL_PROTOCOL variable is $BASE_URL_PROTOCOL"
1213
RUN echo "BASE_URL_DOMAIN variable is $BASE_URL_DOMAIN"
1314
RUN echo "BASE_URL_PORT variable is $BASE_URL_PORT"
1415
RUN echo "BASE_URL_PATH variable is $BASE_URL_PATH"
16+
RUN echo "WEBSOCKET_PROTOCOL variable is $WEBSOCKET_PROTOCOL"
1517

1618
# Install maven
1719
WORKDIR /usr/share
@@ -32,12 +34,14 @@ ADD microservices/playground-ws/src src
3234
# Incremental docker builds will always resume after that, unless you update
3335
# the pom
3436
ADD microservices/playground-ws/pom.xml .
35-
RUN mvn -Dbase.url.protocol="$BASE_URL_PROTOCOL" -Dbase.url.domain="$BASE_URL_DOMAIN" -Dbase.url.port="$BASE_URL_PORT" -Dbase.url.path="$BASE_URL_PATH" package -Prelease -Dmaven.test.skip
37+
RUN mvn -Dbase.url.protocol="$BASE_URL_PROTOCOL" -Dbase.url.domain="$BASE_URL_DOMAIN" -Dbase.url.port="$BASE_URL_PORT" \
38+
-Dbase.url.path="$BASE_URL_PATH" -Dwebsocket.protocol="$WEBSOCKET_PROTOCOL" package -Prelease -Dmaven.test.skip
3639

3740
# Do the Maven build!
3841
# Incremental docker builds will resume here when you change sources
3942
ADD microservices/playground-ws/src src
40-
RUN mvn -Dbase.url.protocol="$BASE_URL_PROTOCOL" -Dbase.url.domain="$BASE_URL_DOMAIN" -Dbase.url.port="$BASE_URL_PORT" -Dbase.url.path="$BASE_URL_PATH" package -Prelease -Dmaven.test.skip
43+
RUN mvn -Dbase.url.protocol="$BASE_URL_PROTOCOL" -Dbase.url.domain="$BASE_URL_DOMAIN" -Dbase.url.port="$BASE_URL_PORT" \
44+
-Dbase.url.path="$BASE_URL_PATH" -Dwebsocket.protocol="$WEBSOCKET_PROTOCOL" package -Prelease -Dmaven.test.skip
4145

4246
RUN echo "done!"
4347

microservices/playground-ws/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
</goals>
8787
<phase>generate-resources</phase>
8888
<configuration>
89-
<arguments>--baseUrlProtocol=${base.url.protocol} --baseUrlDomain=${base.url.domain} --baseUrlPort=${base.url.port} --baseUrlPath=${base.url.path}</arguments>
89+
<arguments>--baseUrlProtocol=${base.url.protocol} --baseUrlDomain=${base.url.domain} --baseUrlPort=${base.url.port} --baseUrlPath=${base.url.path} --websocketProtocol=${websocket.protocol}</arguments>
9090
</configuration>
9191
</execution>
9292
<execution>

web/playground/gulpfile.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { argv } = require('yargs');
22
const fs = require('node:fs');
33

4-
const ConfigurationJs = (protocol, baseUrl, port, path) => `
4+
const ConfigurationJs = (protocol, baseUrl, port, path, websocketProtocol) => `
55
class Configuration {
66
static get protocol() {
77
return "${protocol}";
@@ -18,6 +18,10 @@ class Configuration {
1818
static get path() {
1919
return "${path}";
2020
}
21+
22+
static get websocketProtocol() {
23+
return "${websocketProtocol}";
24+
}
2125
}
2226
2327
export { Configuration };
@@ -29,14 +33,16 @@ function defaultTask(cb) {
2933
const baseUrl = argv.baseUrlDomain;
3034
const port = argv.baseUrlPort;
3135
const path = argv.baseUrlPath;
36+
const websocketProtocol = argv.websocketProtocol;
3237

3338
console.log('=============GULP VARIABLES=============');
3439
console.log(protocol);
3540
console.log(baseUrl);
3641
console.log(port);
3742
console.log(path);
43+
console.log(websocketProtocol);
3844

39-
const configFile = ConfigurationJs(protocol, baseUrl, port, path);
45+
const configFile = ConfigurationJs(protocol, baseUrl, port, path, websocketProtocol);
4046

4147
// create Configuration.js file
4248
fs.writeFileSync(

web/playground/src/screens/playground/Playground.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Configuration } from "../../Configuration";
88
import "./Playground.scss";
99

1010
function Playground() {
11-
const WEBSOCKET_URL = `wss://${Configuration.baseUrl}${Configuration.port ? ":" + Configuration.port : ""}${Configuration.path}api/websocket`;
11+
const WEBSOCKET_URL = `${Configuration.websocketProtocol}://${Configuration.baseUrl}${Configuration.port ? ":" + Configuration.port : ""}${Configuration.path}api/websocket`;
1212
const [program, setProgram] = useState("");
1313
const [history, setHistory] = useState([]);
1414
const [playgroundNotFound, setPlaygroundNotFound] = useState(false);

0 commit comments

Comments
 (0)