Skip to content

Instantly share code, notes, and snippets.

@Reanmachine
Created October 3, 2015 01:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Reanmachine/67d72b2997024cdfd3c8 to your computer and use it in GitHub Desktop.
Save Reanmachine/67d72b2997024cdfd3c8 to your computer and use it in GitHub Desktop.
Bonsai: Users API - Draft 1

Message Packages:

Client -> Server Message Example:

{
    token: string|null - The session token
    type: string - The message type
    payload: object - The payload of the message
}

Server -> Client Message Example:

{
    type: string - The message type
    payload: object - The payload of the message
}

You would have 2 classes of messages, Tokenless and Tokenful. The tokenless operate regardless of the user, the

Client -> Server

login - Tokenless Calls to log in the current session. Payload:

  • username string Duh?
  • password string Duh?

logout Calls to log out the current session Payload:

  • All data embedded in the outer container

getUsers Get user data for a number of user ids? Payload:

  • userIds array An array of user ids to get the information for

Server -> Client

sessionLoggedIn A message to tell the current session that it's now logged in. This message could be used to update a session's token periodically if needed as well. Payload:

  • userId The id of the user
  • token The session token

sessionLoginFailed The login request failed Payload:

  • message The message to display to the user.

dataCollectionUsers A data collection of users Payload (Example):

{
    '23': { // The User ID
        ... User Data Schema Here
    },
    
    ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment