Start building the frontend application.

This commit is contained in:
Dave Smith-Hayes 2024-09-29 22:11:58 -04:00
parent 4570923287
commit 2906fbc529
2 changed files with 15 additions and 2 deletions

View File

@ -9,12 +9,21 @@
<script src="/js/chat-service.js"></script>
<script>
// start the chat web socket
initChatService();
// render the application
const root = document.body;
m.render(root, m("h1", "A Stupid Chat"));
m.render(root, [
m("h1", "A Stupid Chat"),
m("div", [
m("div", { id: "messages" }, [
]).
m("form", { id: "message-form" }, [
])
])
]);
</script>
</body>
</html>

View File

@ -1,3 +1,5 @@
const ws = initChatService();
function initChatService() {
const ws = new WebSocket("ws://localhost:3000/chat-socket");
@ -14,4 +16,6 @@ function initChatService() {
ws.onerror = function (event) {
console.log(event);
};
return ws;
}