contrato-do-backend

Documents the real REST and SignalR contract between the KrockSide frontend and Hibrygame backend.

Updated Jan 28, 2024
One-click install
npx skills add https://github.com/Thiago-Cruz-eng/KrockSide --skill contrato-do-backend-thiago-cruz-eng
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: contrato-do-backend
Source: https://github.com/Thiago-Cruz-eng/KrockSide/tree/main/.agents/skills/contrato-do-backend
Command: npx skills add https://github.com/Thiago-Cruz-eng/KrockSide --skill contrato-do-backend-thiago-cruz-eng

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Frontend developers working on the KrockSide chess client repeatedly hit 404s, undefined fields, and unexpected payloads because parts of the codebase call backend routes that do not exist and declare JWT claims the backend never emits. This Skill records the verified contract so you stop guessing. ## Core Features & Use Cases - Verified REST route table: Lists the eleven REST endpoints that actually exist, plus the three routes in userApi.ts that return 404 (create, get/{id}, refresh). - SignalR hub reference: Documents the ten methods and six events of the /chesshub hub, including quirks like JoinRoom being the only source of player color and the nine exact MakeMove refusal messages. - Data format details: Covers BoardSnapshot/SquareDto/PieceDto shape, camelCase vs PascalCase enum casing, ReferenceHandler.Preserve $id/$values envelopes, and real JWT claim names. - Use Case: Before adding a new backend call or debugging a 404 on user registration, consult this Skill to confirm the correct route, payload, and authorization role instead of copying the broken patterns in userApi.ts. ## Quick Start Ask the AI to check the backend contract before modifying src/service/userApi.ts or investigating why a REST call returns 404.

Frequently Asked Questions about contrato-do-backend

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does user registration return 404 in this React app?

userApi.ts calls POST create, but the backend only exposes POST /users. The same divergence affects GET get/{id} (should be /users/{id}) and POST refresh (should be /refresh-token), so those flows never worked.

How do I get the player color from the SignalR chess hub?

JoinRoom is the only hub method that returns the player color, in its JoinRoomResponse. GetPlayersInEachRoom returns only names without colors, so lobby state must default color to None until JoinRoom completes.

Why are JWT role and emailAddress fields undefined after decoding the token?

The backend emits the role under the long claim key http://schemas.microsoft.com/ws/2008/06/identity/claims/role, not role, and never emits emailAddress. The auth type declarations listing those fields are wrong and always decode to undefined.

Does the backend return errors as exceptions or response bodies?

REST failures come back as bodies with success: false and a message, with varying HTTP statuses, so decide by the success field rather than status code. Hub invocation errors return success: false in the method result and never emit an event.

Why do REST list fields like assignments arrive in an unexpected format?

The backend serializes controllers with ReferenceHandler.Preserve, so responses can contain $id markers, $ref references, and lists wrapped as $values arrays. Nothing in the frontend currently unwraps this envelope, and it does not apply to SignalR payloads.