- Route
/: Homepage - Route
/rules: Game rules page - Route
/game: Game page for both full and demo game. Visiting this route does not automatically start a game; instead, there is a button to manually start a new game session. - Route
/login: User authentication page
-
POST
/api/sessions- Request body:
{ username: user1, password: password }- Response:
201 Created. The body content is the following:
{ id: 1, email: user1@gmail.com, username: user1, coins: 100, gamesCount: 1, }422 Unprocessable Contenton validation failure:
{ errors: [ { type: 'field', value: '', msg: "E' richiesto l'username", path: 'username', location: 'body' } ] } -
GET
/api/sessions/current- Request body: none
- Response:
200 OKwith the current authenticated user:
{ id: 1, email: user1@gmail.com, username: user1, coins: 100, gamesCount: 1, }401 Unauthorizedif not authenticated:
{ error: "Non autenticato" }
-
DELETE
/api/sessions/current- Request body: none
- Response:
200 OKwith empty body (logout completed)
-
GET
/api/game/letters- Request body: none
- Response:
200 OKwith the list of consonants and their costs:
[ { letter: "B", cost: 2 }, { letter: "C", cost: 3 }, ... ]500 Internal Server Erroron unexpected errors:
{ error: string }
-
POST
/api/game/start- Request body: none
- Response:
201 Createdwith the new game info:
{ grid: [5, 2, 7, 4], gameID: "1" }409 Conflictif a game is already running or coins are insufficient (for authenticated users):
{ error: "Monete insufficienti" }500 Internal Server Erroron unexpected errors
-
POST
/api/game/guessletter/:letter-
URL params:
letter: a single alphabetic character (A–Z or a–z)
-
Request body: none
-
Response:
200 OKwith the attempt result:
// Demo game, lettera presente { correct: true, letter: "R", positions: [0, 3] } // Demo game, lettera assente { correct: false } // Gioco autenticato, lettera presente (include le monete aggiornate) { correct: true, letter: "R", positions: [0, 3], coins: 97 } // Gioco autenticato, lettera assente (include le monete aggiornate) { correct: false, coins: 94 } -
422 Unprocessable Contenton validation failure:{ "errors": [ { "type": "field", "value": "1", "msg": "La lettera deve essere un carattere alfabetico singolo", "path": "letter", "location": "params" } ] } -
400 Bad Requestfor game errors such as already tried letter, vowel already attempted, or insufficient coins to attempt the letter:{ error: "Lettera già tentata" } -
500 Internal Server Erroron unexpected errors
-
-
POST
/api/game/guessphrase- Request body:
{ phrase: "frase con solo lettere e spazi" }-
Response:
200 OK:
// Frase corretta (demo): { win: true, phrase: "..." } // Frase corretta (utente autenticato) { win: true, phrase: "...", coins: 200 } // Tempo scaduto all'arrivo della richiesta { win: false, timeElapsed: true } -
422 Unprocessable Contenton validation failure:{ "errors": [ { "type": "field", "value": "frase corta", "msg": "La frase deve essere lunga tra 30 e 50 caratteri", "path": "phrase", "location": "body" } ]
}
- `400 Bad Request` for game errors - `500 Internal Server Error` on unexpected errors -
POST
/api/game/end-
Request body: none
-
Response:
-
200 OKwith final game outcome. Possible responses:// Demo, tempo scaduto { win: false, phrase: "...", timeElapsed: true } // Demo, tempo non scaduto (vince se la frase era corretta) { win: true, phrase: "..." } // Utente autenticato, tempo non scaduto { win: true, phrase: "...", coins: 180 } // se aveva indovinato { win: false, phrase: "...", coins: 150 } // se non aveva indovinato // Utente autenticato, tempo scaduto (penalità) { win: false, phrase: "...", timeElapsed: true, coins: 130 } -
400 Bad Requestfor game errors (e.g., game not found) -
500 Internal Server Erroron unexpected errors
-
- Table
users- contains id (PK), username, email, password, salt, coins, gamescount. - Table
phrases- contains id (PK), phrase. - Table
phrases_demo- contains id (PK), phrase. - Table
letters- contains letter (PK), cost.
Homepage(inHomepage.jsx): Landing page with hero section and user info (for authenticated user).Rules(inRules.jsx): Game rules explanation component.LoginForm(inLoginForm.jsx): User authentication form.Game(inGame.jsx): Layout of game components and handlers for game events.NotFound(inNotFound.jsx): 404 error page for invalid routes.DefaultLayout(inDefaultLayout.jsx): Standard layout for most pages (not game).
- username: test@test.it, password: test (user who played some games).
- username: user@user.it, password: user (user with 0 coins).
- username: newuser@user.it, password: user (user who played 0 games).
