Skip to content

Bachmair-Boys/pickup-game-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pickup-game-server

Setup

Ensure that you have the latest version of MariaDB and NodeJS installed. Once MariaDB is setup and running (usually involves setting up an account and a password), do:

git clone https://github.com/Bachmair-Boys/pickup-game-server
cd pickup-game-server

Edit setup_db.sh and modify the variables MYSQL_USER_NAME and MYSQL_PASSWORD so that they match your MariaDB username and password. Set up the database:

./setup_db.sh

Running

node index.js

API

Types

GameType: enum { "BASEBALL", "BASKETBALL", "SOCCER" }
VisibilityType: enum { "PUBLIC", "PRIVATE" }
Date: "YYYY-MM-DD HH:MM:SS"
Game: {
     name: string, name of game.
     id: int, id of game.
     user_name: string, username of user hosting game.
     type: GameType, type of game.
     visibility: VisibilityType, specifies who can see the game.
     latitude: float, latitude of game.
     longitude: float, longitude of game.
     until: Date, time that game lasts until
    }

Methods

register-user: GET, Registers a user.
Parameters:
    user_name: string, username of user.
    email: string, user's email.
    password: string, user's password
Return:
    JSON-Encoded Data: {
     status: int, SUCCESS if registration succeeded, USER_REGISTRATION_ERROR otherwise
     token: string, token to be used for actions that require authentication.     }

is-email-in-use: GET, checks if the specified email is in use.
Parameters:
    email: string, email to check if in use.
Return:
    JSON-Encoded Data: {
     status: int, SUCCESS if check succeeded, DATABASE_LOOKUP_ERROR otherwise,
     is_in_use: boolean, true if email is in use, false otherwise.
    }

is-user-name-in-use: GET, checks if the specified user-name is in use.
Parameters:
    user_name: string, username to check if in use.
Return:
    JSON-Encoded Data: {
     status: int, SUCCESS if check succeeded, DATABASE_LOOKUP_ERROR otherwise,
     is_in_use: boolean, true if username is in use, false otherwise.
    }

log-in: POST, Logs in a user. Returns a token to be used for actions that require authentication.
Parameters:
    user_name: string, user's username.
    password: string, user's password.
Return:
    JSON-Encoded Data: {
     status: int, SUCCESS if log-in succeeded, otherwise AUTHENTICATION_ERROR or DATABASE_LOOKUP_ERROR
     token: string, token to be used for actions that require authentication.
    }

log-out: POST, Logs out a user. Parameters:
    user_name: string, user's username.
    token: string, user's login token. Return:
    JSON-Encoded Data: {
     status: int, SUCCESS if log-out succeeded, otherwise INVALID_TOKEN_ERROR or DATABASE_LOOKUP_ERROR
    }

is-valid-token: GET, Checks if a token is valid for a specified user.
Parameters:
    username: string, user's username.
    token: string, user's login token.
Return:
    JSON-Encoded Data: {
     status: int, SUCCESS if check succeeded, DATABASE_LOOKUP_ERROR otherwise.
     is_valid: boolean, true if the token is valid, false otherwise.
    }

start-game: POST, Starts a new game and returns the game ID.
Parameters:
    username: string, The username of the user starting the game.
    token: string, The login token for the user.
    name: string, The name of the game.
    type: GameType, The type of the game being started.
    visibility: VisibilityType: Specifies who can see the game.
    latitude: float, The latitude of the game location.
    longitude: float, The longitude of the game location
    until: Date, The time the game lasts until.
Return:
    JSON-Encoded Data: {
     status: int, SUCCESS if game was able to start, DATABASE_UPDATE_ERROR otherwise.
     id: int, The ID of the game.
    }

end-game: POST, Ends a game. Parameters:
    username: string, The username of the user ending the game.
    token: string, The login token for the user.
    game_id: int, The ID of the game being ended.
Return:
    JSON-Encoded Data: {
     status: int, SUCCESS was ended, DATABASE_UPDATE_ERROR otherwise.
    }

does-user-have-game-running: GET, Checks whether a user has a game running.
Parameters:
    username: string, The username of the user being checked.
Return:
    JSON-Encoded Data: {
     status: int, SUCCESS if game check succeeded, DATABASE_LOOKUP_ERROR otherwise.
     has_game_running: boolean, Whether the user has a game running.
    }

find-game: GET, Finds games around a user.
Parameters:
    latitude: float, The user's latitude.
    longitude: float, The user's longitude.
    radius: float, The maximum distance a game can be from the user, in kilometers.
Return:
    JSON-Encoded Data: {
     status: int, SUCCESS if able to look for games, DATABASE_LOOKUP_ERROR otherwise.
     games: Game[], Array of games.
    }

About

Backend for the PickupGame app

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors