api - JohnTimmermann/OpenHud GitHub Wiki
Versioned and organized by features for scalability.
Base URL:
localhost:{port}/api/{feature}
Think of these as traffic signs.
- Define API endpoints
- Route HTTP requests to the appropriate controller
Think of these as the receptionists.
- Receive and validate incoming requests
- Communicate with the appropriate service
- Send responses back to the client
Think of these as the workers using the blueprints.
- Contain the core business logic
- Interact with models to fetch/update data
- Handle transactions via
run_transaction
utility- SQL statements are committed if successful, rolled back on failure
- Return Promises: resolve with result or reject with error
Think of these as the blueprints of the data.
- Define the structure of the data
- Run direct SQL queries on the database
- Return Promises (important for SQLite3): resolve with result or reject with error
- Client sends a request to
/api/{feature}
- Router forwards the request to the appropriate Controller
- Controller calls the corresponding Service for business logic
- Service uses the Model to interact with the database
Data flows back:
Model → Service → Controller → Client
-
_id
– Unique UUID generated in the service -
username
– Editable display name (not Steam username) -
steamid
– Used to associate game data and HUD with correct player
firstName
lastName
-
avatar
– Path to image inplayer_pictures/
country
-
team
– Foreign key linking toteams._id
-
extra
– (Currently unused)
-
_id
– Unique UUID generated in the service -
name
– Full team/organization name
country
-
shortName
– Abbreviated name (for long names) -
logo
– Path to image inteam_logos/
-
extra
– (Currently unused)
-
_id
– Unique UUID generated in the service
(To be defined)