Skip to content
Kevinoh47 edited this page Dec 11, 2018 · 16 revisions

Welcome to the apiServices wiki for the enSeven online game!

ApiServices, Client, and Game Engine teams are working together to build out our game. The ApiServices team is James Denton, Hai Le, Ed Puzino, and Kevin O'Halloran.

API Services

The API server provides the interface to the persistence layer, which is implemented using MongoDb. When users sign up, or return to play again, the API is accessed. The game engine uses API services to persist and retrieve information about wins and losses.

The Auth layer supports regular authorization (name + password) as well as "bearer auth", which passes an encoded token back to the game engine to use in subsequent writes and reads to and from the API. After signing in with user name and password, the token allows the client to identify the gamer on subsequent requests without requiring the gamer to type in his or her credentials more than once per session. Furthermore, the game engine can use the token on the gamer's behalf as necessary as it writes data or requests data from the API layer.

Get and Post routes are protected by Auth middleware where appropriate. In most cases this middleware checks for expected permissions ("capabilities") as well as authenticating the user's identity, before granting access to the requested service.

The API layer implements a simple Access Control List (ACL) architecture for tracking users and their permissions. Users are assigned a role (typically "gamer"), which has a specific list of privileges (called "capabilities.")

The game client communicates directly only with the game engine. The API communicates directly only with the game engine. Consequently in certain cases, such as signup, the game engine passes along requests from the client to the API and vice versa. In other cases, the game engine is delegated by the client to communicate directly with the API layer as appropriate.

Routes

The above functionality is exposed via routes. The first supported routes are as follows:

  • /signup (Post) This route is used to persist a new user such as a gamer to the system; it returns a token to be used by subsequent calls.
  • /signin (Post) This route checks a returning user's credentials. If the user's name and password match, a token is returned that can be used for subsequent calls.
  • /api/v1/singlestat (Get and Post) The game engine uses this post route to post the gamer's results to the database. This route also automatically updates the aggregated player stats. The get route could be used to retrieve all results.
  • /api/v1/playerstats (Get and Post) The post route could be used to update aggregated player data, although currently this is handled automatically via a post save hook on the post singlestat route. The get route could be used by the game engine to return all aggregated stats.
  • /api/v1/my/singlestat/(playername) (Get) This route can be used to get all the individual gaming records for an individual gamer.
  • /api/v1/my/playerstats/(playername) (Get) This route can be used to retrieve the single aggregate record for an individual gamer. This route can be used to retrieve the single aggregate record for an individual gamer.

Clone this wiki locally