Skip to content

Commit a643eda

Browse files
committed
updated gitignore
1 parent 2eb2b49 commit a643eda

12 files changed

+20
-18
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
.env
33
.env*
44

5+
# dist
6+
dist
7+
58
# Logs
69
logs
710
*.log

app.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ const wsServer = new WebSocketServer({
1010
noServer: true,
1111
});
1212

13-
1413
const main = async () => {
15-
1614
wsServer.on("connection", (socket) => {
17-
socket.on("message", (message) =>
18-
console.log("socket.on(message)", message)
19-
);
15+
socket.on("message", (message) => {
16+
console.log("SERVER RECEIVED: socket.on(message)", JSON.parse(message));
17+
// echo the user
18+
socket.send(JSON.stringify({ message: "hello client" }));
19+
});
2020
});
2121

2222
app.use(bodyParser.json());
@@ -29,7 +29,7 @@ const main = async () => {
2929
app.use("/routes", routes);
3030

3131
var server = http.createServer(app);
32-
server.listen(3000);
32+
server.listen(ConfigurationData.server.port);
3333
server.on("upgrade", (request, socket, head) => {
3434
wsServer.handleUpgrade(request, socket, head, (socket) => {
3535
wsServer.emit("connection", socket, request);
@@ -38,7 +38,6 @@ const main = async () => {
3838

3939
console.info(`Server started on port ${ConfigurationData.server.port}`);
4040
console.info(`http://127.0.0.1:${ConfigurationData.server.port}`);
41-
4241
};
4342

4443
main().catch(console.error);

dist/assets/index-47436ed6.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>vue3-vite-express-js-boilerplatee</title>
88
<style></style>
9-
<script type="module" crossorigin src="/assets/index-47436ed6.js"></script>
9+
<script type="module" crossorigin src="/assets/index-b57d86e3.js"></script>
1010
</head>
1111
<style lang="scss">
1212
:root {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"dev": "vite --mode development",
1010
"build": "vite build --mode development",
1111
"preview": "vite preview",
12-
"start": "node app",
12+
"start": "vite build --mode development && node app",
1313
"prepare": "husky install"
1414
},
1515
"lint-staged": {

public/android-chrome-192x192.png

15.6 KB
Loading

public/android-chrome-512x512.png

48.8 KB
Loading

public/apple-touch-icon.png

13.9 KB
Loading

public/favicon-16x16.png

770 Bytes
Loading

public/favicon-32x32.png

1.78 KB
Loading

public/favicon.ico

15 KB
Binary file not shown.

src/composables/useStatusDetails.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
import { computed, ref, reactive } from "vue";
22

33
export function useDeviceDetails() {
4+
let websocketConnection = "";
5+
if (location.protocol.includes("https"))
6+
websocketConnection = `wss://${location.host}`;
7+
else websocketConnection = `ws://${location.host}`;
48

59
const status = ref({});
610

7-
const ws = new WebSocket("ws://localhost:6909");
11+
const ws = new WebSocket(websocketConnection);
12+
813
ws.onmessage = function (event) {
914
let message = JSON.parse(event.data);
1015
console.log("RECEIVED WEB MESSAGE INSIDE useDeviceDetails: ", message);
1116
};
12-
17+
1318
ws.onopen = function (event) {
1419
console.log(
1520
"Successfully connected to the echo websocket server from useDeviceDetails..."
1621
);
17-
ws.send("Hello");
22+
ws.send(JSON.stringify({ message: "hello server" }));
1823
};
1924

2025
return {
21-
status
26+
status,
2227
};
2328
}

0 commit comments

Comments
 (0)