Skip to content

A service that manages a game that uses a leaderboard with players submitting new scores from around the world.

License

Notifications You must be signed in to change notification settings

aylingumus/leaderboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

leaderboard

A service that manages a game that uses a leaderboard with players submitting new scores from around the world. I used NodeJS with Express framework and PostgreSQL database for this application.

Running Locally

To initialize NodeJS application run commands below:

git clone https://github.com/aylingumus/leaderboard.git
cd leaderboard
npm install
npm start

Sample Requests and Responses

GET /leaderboard: You can get global leaderboard data.
Sample Response:

[
    {
        "rank": 1,
        "points": "400",
        "display_name": "player_1",
        "country": "tr"
    },
    {
        "rank": 2,
        "points": "280",
        "display_name": "player_2",
        "country": "tr"
    },
    {
        "rank": 3,
        "points": "190",
        "display_name": "player_3",
        "country": "us"
    }
]

GET /leaderboard/{country_iso_code}: You can get country specific leaderboard data.
Sample Response:

[
    {
        "rank": 4,
        "points": "117",
        "display_name": "player_5",
        "country": "eu"
    },
    {
        "rank": 7,
        "points": "10",
        "display_name": "player_7",
        "country": "eu"
    },
    {
        "rank": 8,
        "points": "0",
        "display_name": "player_8",
        "country": "eu"
    }
]

GET /user/profile/{user_guid}: You can get user data by user GUID.
Sample Response:

{
    "user_id": "a7f3ed72-84f5-4adc-a16b-ccad82611474",
    "display_name": "player1",
    "points": "280",
    "rank": 2
}

POST /user/create: You can create a new user. New user will be ranked as the last automatically.
Sample Request:

{
	"display_name": "player2",
	"country": "tr"
}

Sample Response:

{
    "user_id": "f16743ed-b70d-4f5e-bb84-2482b53da12c",
    "display_name": "player2",
    "points": "0",
    "rank": 8
}

POST /score/submit: You can submit a score worth for an existing user. This score submission affects the rank orders.
Sample Request:

{
	"score_worth": 15,
	"user_id": "a666c433-666c-498e-9539-200d54917666"
}

Sample Response:

{
    "score_worth": "15",
    "user_id": "a666c433-666c-498e-9539-200d54917666",
    "timestamp": 1592762472.153
}

About

A service that manages a game that uses a leaderboard with players submitting new scores from around the world.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published