From 4742a6010088b5b034a13ed066f316f81d804083 Mon Sep 17 00:00:00 2001 From: Nameless <132124594+thenamelessdev@users.noreply.github.com> Date: Tue, 6 Jan 2026 20:28:05 +0100 Subject: [PATCH 1/8] started coding --- src/routes/projects.ts | 3 +++ src/routes/typeword.ts | 19 ++++++++++++++++ views/projects/typeword/index.ejs | 37 +++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 src/routes/typeword.ts create mode 100644 views/projects/typeword/index.ejs diff --git a/src/routes/projects.ts b/src/routes/projects.ts index fd63bd6..98c7354 100644 --- a/src/routes/projects.ts +++ b/src/routes/projects.ts @@ -4,6 +4,9 @@ const router = express.Router(); import tttRouter from "./ttt.js"; router.use("/ttt", tttRouter); +import typeWordRouter from "./typeword.js"; +router.use("/typeword", typeWordRouter); + router.get("/", (req: Request, res: Response) => { res.render("projects"); }); diff --git a/src/routes/typeword.ts b/src/routes/typeword.ts new file mode 100644 index 0000000..d4ef806 --- /dev/null +++ b/src/routes/typeword.ts @@ -0,0 +1,19 @@ +import express, { Request, Response } from "express"; +const router = express.Router(); + +router.get("/", (req: Request, res: Response) => { + res.render("projects/typeword/index") +}); + +router.post("/create", (req: Request, res: Response) => { + const { username, room } = req.body; + + if(username && room){ + + } + else{ + res.status(400).render("error", { error: "missing username or room name" }); + } +}); + +export default router; \ No newline at end of file diff --git a/views/projects/typeword/index.ejs b/views/projects/typeword/index.ejs new file mode 100644 index 0000000..0bb2181 --- /dev/null +++ b/views/projects/typeword/index.ejs @@ -0,0 +1,37 @@ + + + + + + TypeWord + + + + +

TypeWord

+

A fun game to play with friends

+

How to play: after both players join the room the game will give you a world. You have to type the word as fast as you can and whoewer types it faster wins.

+
+
+
Create Room
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+ +
+
+ + \ No newline at end of file From 69c7bf6b0a49420043e2eb6819e07f848cba40f0 Mon Sep 17 00:00:00 2001 From: Nameless <132124594+thenamelessdev@users.noreply.github.com> Date: Tue, 6 Jan 2026 20:38:37 +0100 Subject: [PATCH 2/8] added cf turnstile --- src/routes/typeword.ts | 19 +++++++++++++++++-- views/projects/typeword/index.ejs | 9 ++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/routes/typeword.ts b/src/routes/typeword.ts index d4ef806..5c94745 100644 --- a/src/routes/typeword.ts +++ b/src/routes/typeword.ts @@ -1,15 +1,30 @@ import express, { Request, Response } from "express"; +import { verify } from "../functions.js"; const router = express.Router(); +interface typeWordRoom { + name: string, + host: string, + player?: string, + winner?: string, +} + +let rooms: Record = {}; + router.get("/", (req: Request, res: Response) => { res.render("projects/typeword/index") }); -router.post("/create", (req: Request, res: Response) => { +router.post("/create", async (req: Request, res: Response) => { const { username, room } = req.body; if(username && room){ - + if(await verify(req)){ + + } + else{ + res.render("error", { error: "Cloudflare turnstile failed" }); + } } else{ res.status(400).render("error", { error: "missing username or room name" }); diff --git a/views/projects/typeword/index.ejs b/views/projects/typeword/index.ejs index 0bb2181..114c41d 100644 --- a/views/projects/typeword/index.ejs +++ b/views/projects/typeword/index.ejs @@ -7,6 +7,11 @@ +

TypeWord

@@ -22,7 +27,7 @@ - +
@@ -30,6 +35,8 @@

+
+
From 5097d827c7e7fee5608101ef9534ac7a7e9abf33 Mon Sep 17 00:00:00 2001 From: Nameless <132124594+thenamelessdev@users.noreply.github.com> Date: Tue, 6 Jan 2026 20:51:38 +0100 Subject: [PATCH 3/8] made game page --- src/routes/typeword.ts | 13 +++++++++++-- views/projects/typeword/game.ejs | 23 +++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 views/projects/typeword/game.ejs diff --git a/src/routes/typeword.ts b/src/routes/typeword.ts index 5c94745..2c87117 100644 --- a/src/routes/typeword.ts +++ b/src/routes/typeword.ts @@ -9,7 +9,7 @@ interface typeWordRoom { winner?: string, } -let rooms: Record = {}; +export let typeWordRooms: Record = {}; router.get("/", (req: Request, res: Response) => { res.render("projects/typeword/index") @@ -20,7 +20,16 @@ router.post("/create", async (req: Request, res: Response) => { if(username && room){ if(await verify(req)){ - + if(typeWordRooms[room]){ + res.render("error", { error: "Room name already exists" }); + } + else{ + typeWordRooms[room] = { + name: room, + host: username + } + res.render("projects/typeword/game", { room: room, user: username, host: username, player: "none" }); + } } else{ res.render("error", { error: "Cloudflare turnstile failed" }); diff --git a/views/projects/typeword/game.ejs b/views/projects/typeword/game.ejs new file mode 100644 index 0000000..dfd5340 --- /dev/null +++ b/views/projects/typeword/game.ejs @@ -0,0 +1,23 @@ + + + + + + TypeWord - <%= room %> + + + + +

<%= room %>

+

Host: <%= host %>

+

You: <%= user %>

+

Player: <%= player %>

+ + + + + \ No newline at end of file From 994cfb85dbba4b65c9161d2fb5ebb56c3ffd3964 Mon Sep 17 00:00:00 2001 From: Nameless <132124594+thenamelessdev@users.noreply.github.com> Date: Wed, 7 Jan 2026 19:42:12 +0100 Subject: [PATCH 4/8] added player join --- src/routes/typeword.ts | 24 ++++++++++++++++++++++++ views/projects/typeword/game.ejs | 12 ++++++++++-- views/projects/typeword/index.ejs | 24 ++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/routes/typeword.ts b/src/routes/typeword.ts index 2c87117..a53ebbe 100644 --- a/src/routes/typeword.ts +++ b/src/routes/typeword.ts @@ -1,5 +1,6 @@ import express, { Request, Response } from "express"; import { verify } from "../functions.js"; +import { io } from "../index.js"; const router = express.Router(); interface typeWordRoom { @@ -40,4 +41,27 @@ router.post("/create", async (req: Request, res: Response) => { } }); +router.post("/join", async (req: Request, res: Response) => { + const { username, room } = req.body; + + if(username && room){ + if(await verify(req)){ + if(typeWordRooms[room]){ + typeWordRooms[room].player = username; + io.emit("typewordjoin", {"room": room, "username": username}); + res.render("projects/typeword/game", { room: room, user: username, host: typeWordRooms[room].host, player: username }); + } + else{ + res.status(404).render("error", { error: "Room doesn't exists" }) + } + } + else{ + res.render("error", { error: "Cloudflare turnstile failed" }); + } + } + else{ + res.status(400).render("error", { error: "missing username or room name" }); + } +}); + export default router; \ No newline at end of file diff --git a/views/projects/typeword/game.ejs b/views/projects/typeword/game.ejs index dfd5340..739f3cb 100644 --- a/views/projects/typeword/game.ejs +++ b/views/projects/typeword/game.ejs @@ -12,12 +12,20 @@

<%= room %>

Host: <%= host %>

You: <%= user %>

-

Player: <%= player %>

+

Player: <%= player %>

- + \ No newline at end of file diff --git a/views/projects/typeword/index.ejs b/views/projects/typeword/index.ejs index 114c41d..cb70348 100644 --- a/views/projects/typeword/index.ejs +++ b/views/projects/typeword/index.ejs @@ -40,5 +40,29 @@ + + +
+
Join Room
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+
+
+ +
+
\ No newline at end of file From a45e569354147ce9b8517db23e38d0fec312709d Mon Sep 17 00:00:00 2001 From: Nameless <132124594+thenamelessdev@users.noreply.github.com> Date: Wed, 7 Jan 2026 19:44:12 +0100 Subject: [PATCH 5/8] style updates --- views/projects/typeword/index.ejs | 1 + 1 file changed, 1 insertion(+) diff --git a/views/projects/typeword/index.ejs b/views/projects/typeword/index.ejs index cb70348..d04a021 100644 --- a/views/projects/typeword/index.ejs +++ b/views/projects/typeword/index.ejs @@ -41,6 +41,7 @@ +
Join Room
From 02d9a951a1eeb3bb28266742093664f662808003 Mon Sep 17 00:00:00 2001 From: Nameless <132124594+thenamelessdev@users.noreply.github.com> Date: Wed, 7 Jan 2026 21:05:28 +0100 Subject: [PATCH 6/8] made start button and added word api --- src/index.ts | 16 ++++++++++++ views/projects/typeword/game.ejs | 45 +++++++++++++++++++++++++++++--- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 6af611d..d03f460 100644 --- a/src/index.ts +++ b/src/index.ts @@ -136,6 +136,22 @@ io.on("connection", async (socket) => { io.emit("delete", ({ room: room })); delete rooms[room]; }); + + socket.on("typewordstart", async (data) => { + try{ + const response = await fetch("https://random-word-api.herokuapp.com/word"); + const json = await response.json(); + if(response.ok){ + io.emit("typewordstart", {"room": data.room, "word": json[0]}); + } + else{ + io.emit("typewordstart", {"room": data.room, "word": "error"}); + } + } + catch{ + io.emit("typewordstart", {"room": data.room, "word": "error"}); + } + }); }); server.listen({port, host: "0.0.0.0"}); \ No newline at end of file diff --git a/views/projects/typeword/game.ejs b/views/projects/typeword/game.ejs index 739f3cb..3d37c66 100644 --- a/views/projects/typeword/game.ejs +++ b/views/projects/typeword/game.ejs @@ -13,19 +13,58 @@

Host: <%= host %>

You: <%= user %>

Player: <%= player %>

- +
+ +

Word:

+

+ + +
+ +
+ +
\ No newline at end of file From 03fc0d321a24bd9ba9323054c5b4e9d891128238 Mon Sep 17 00:00:00 2001 From: Nameless <132124594+thenamelessdev@users.noreply.github.com> Date: Thu, 8 Jan 2026 06:53:29 +0100 Subject: [PATCH 7/8] made game functionality --- src/index.ts | 6 ++++++ views/projects/typeword/game.ejs | 36 +++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index d03f460..869c2dd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,6 +11,7 @@ import { rooms } from "./routes/ttt.js"; import { readFileSync, writeFileSync } from "fs"; import { addClick, getClicks, getMessage, setMessage } from "./functions.js"; import * as discojs from "@thenamelessdev/discojs"; +import { typeWordRooms } from "./routes/typeword.js"; //vars and conf dotenv.config(); @@ -152,6 +153,11 @@ io.on("connection", async (socket) => { io.emit("typewordstart", {"room": data.room, "word": "error"}); } }); + + socket.on("typewordfinish", (data) => { + typeWordRooms[data.room].winner = data.player; + io.emit("typewordwinner", {"room": data.room, "player": data.player}); + }); }); server.listen({port, host: "0.0.0.0"}); \ No newline at end of file diff --git a/views/projects/typeword/game.ejs b/views/projects/typeword/game.ejs index 3d37c66..61b0c9d 100644 --- a/views/projects/typeword/game.ejs +++ b/views/projects/typeword/game.ejs @@ -17,6 +17,11 @@

Word:

+
+ +
+
+

Time: 0s


@@ -33,6 +38,10 @@ const playerText = document.getElementById("playerText"); const wordText = document.getElementById("wordText"); const startGameBtn = document.getElementById("startGameBtn"); + const timeText = document.getElementById("timeText"); + const wordInp = document.getElementById("wordInp"); + let word; + let time = 0; if(you == host){ startGameBtn.disabled = false; @@ -42,6 +51,22 @@ socket.emit("typewordstart", {"room": room}); } + function checkWord(){ + if(wordInp.value == word){ + const finishTime = time; + time = undefined; + socket.emit("typewordfinish", {"room": room, "time": finishTime, "player": you}); + } + } + + setInterval(() => { + if(word){ + time = time + 0.01; + timeText.textContent = `Time: ${time.toFixed(2)}`; + checkWord(); + } + }, 10); + socket.on("typewordjoin", (data) => { if(data.room == room){ @@ -49,6 +74,14 @@ } }); + socket.on("typewordwinner", (data) => { + if(data.room = room){ + word = undefined; + time = 0; + timeText.textContent = `Winner: ${data.player}`; + } + }); + socket.on("typewordstart", (data) => { if(data.room == room){ wordText.textContent = "3"; @@ -57,7 +90,8 @@ setTimeout(() => { wordText.textContent = "1"; setTimeout(() => { - wordText.textContent = data.word + word = data.word; + wordText.textContent = word; }, 1000); }, 1000); }, 1000); From d685ad34e710a3e6258ca1d8dbaf3ed3cd5f1b49 Mon Sep 17 00:00:00 2001 From: Nameless <132124594+thenamelessdev@users.noreply.github.com> Date: Thu, 8 Jan 2026 06:55:08 +0100 Subject: [PATCH 8/8] change changelog and add typeword to list --- changelog.txt | 2 +- views/projects.ejs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 3f67336..90ad678 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1 +1 @@ -added new project: crasher, update styles for tik tak toe \ No newline at end of file +New mayor project: TypeWord. Check it out in the projects tab \ No newline at end of file diff --git a/views/projects.ejs b/views/projects.ejs index ccd74dd..96a39e9 100644 --- a/views/projects.ejs +++ b/views/projects.ejs @@ -40,6 +40,8 @@
Crasher
+ TypeWord +

© 2025 thenamelessdev. Licensed under the MIT license.

By using the website you aggree to our privacy policy