kodekulture / wordle-server

Multiplayer wordle game πŸš€
7 stars 1 forks source link
badgerdb golang golang-game postgres real-time websocket

Wordle Server

Sections

Logic 🧠

Data πŸ—ƒ

Permanent (SQL)

Temporary (In-memory/NoSQL)

Struct πŸ’Ύ

Endpoints 🌐

[POST] /login πŸšͺ

Fields ```json { "username": "username", "password": "password" } ```
Response ```json { "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2Vybm" } ```

[POST] /register πŸ“

Fields ```json { "username": "username", "password": "password" } ```
Response ```json { "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2Vybm" } ```

[POST] /create/room πŸ”’

Response ```json { "id": "58dbe7f6-9d5c-4d48-8eac-73db92d4437d" } ```

[GET] /join/room/{id} πŸ”’

Response ```json { "token": "cb6fddb2f88acfcbbdc6c9900510" } ```

[GET] /room/ πŸ”’

Response ```json [ { "created_at": "2023-06-19T19:51:58.802+03:00", "started_at": "2023-06-19T19:53:02.886447+03:00", "ended_at": "2023-06-19T19:51:58.802+03:00", "creator": "username", "correct_word": "FOLKS", "id": "58dbe7f6-9d5c-4d48-8eac-73db92d4437d" }, ... ] ```

[GET] /room/{roomID} πŸ”’

Response ```json { "created_at": "2023-06-19T19:51:58.802+03:00", "started_at": "2023-06-19T19:53:02.886447+03:00", "ended_at": "2023-06-19T19:51:58.802+03:00", "creator": "username", "correct_word": "FOLKS", "guesses": [ { "word": "FOLKS", "played_at": "2023-06-19T16:53:27.581099801Z", "status": [3,3,3,3,3] }, ... ], "game_performance": [ { "rank": 0, "username": "escalopa", "guess_response": { "played_at": "2023-06-19T16:53:27.581099801Z", "status": [3,3,3,3,3] } }, ... ], "id": "58dbe7f6-9d5c-4d48-8eac-73db92d4437d" } ```

Websockets πŸš€

[WS] /live?token=XXXXX

[WSE] server/message

Fields ```json { "data": "Hello World" } ```

[WSE] client/message

Fields ```json { "data": "Hello World", "from": "username" } ```

[WSE] server/play

Fields ```json { "event": "server/play", "data": "FOLKS" } ```

[WSE] client/play

Fields ```json { "event": "client/play", "data": { "rank_offset": 0, "username": "escalopa", "guess_response": { "played_at": "2023-06-19T19:16:36.715290087Z", "status": [1,2,2,1,3] } }, "from": "escalopa" } ```

[WSE] server/start

Fields ```json { "event": "server/start", } ```

[WSE] client/start

Fields ```json { "event": "server/start", "data": "Game has started"", } ```

[WSE] client/data

Fields ```json { "event": "client/data", "data": { "guesses": [ { "word": "FOLKS", "played_at": "2023-06-19T19:16:36.715290087Z", "status": [1,2,2,1,3] } ], "active": true, "board": [ "escalopa" ] }, "from": "" } ```

Future Game Modes ✨