Skip to content

Instantly share code, notes, and snippets.

@gangstead
Last active August 29, 2015 14:11
Show Gist options
  • Save gangstead/cb7104e79240a2f6baa7 to your computer and use it in GitHub Desktop.
Save gangstead/cb7104e79240a2f6baa7 to your computer and use it in GitHub Desktop.
RankTank API

ranktank

The back end of Rank Tank

Building

> npm install

Running the back end

> node app

How can I tell if the back end is even running?

Hit the url http://localhost:3000/index.html for a shiny landing page.

API ideas

A work in progress

get /ranks

Ordered composite of all users' rankings. Includes all items.

  • Option1
[
	{ "id" : "3", "title" : "c"},
	{ "id" : "1", "title" : "a"},
	{ "id" : "2", "title" : "b"},
	{ "id" : "4", "title" : "d"}
]
  • Option2
[
	{ "rank": "1", "id" : "3", "title" : "c"},
	{ "rank": "2", "id" : "1", "title" : "a"},
	{ "rank": "2", "id" : "2", "title" : "b"},
	{ "rank": "4", "id" : "4", "title" : "d"}
]

getorpost /ranks/user/:userId

One user's personal ranking

lower index = higher priority

  • get /ranks/user/steven
[
	{ "id" : "3", "title" : "c"},
	{ "id" : "2", "title" : "b"},
	{ "id" : "1", "title" : "a"}
]
  • get /ranks/user/sam
[
	{ "id" : "3", "title" : "c"},
	{ "id" : "1", "title" : "a"},
	{ "id" : "4", "title" : "d"}
]

Internal representation

What's stored in the service

{
	"steven" : [
		{ "id" : "3", "title" : "c"},
		{ "id" : "2", "title" : "b"},
		{ "id" : "1", "title" : "a"}
	],
	"sam" : [
		{ "id" : "3", "title" : "c"},
		{ "id" : "1", "title" : "a"},
		{ "id" : "4", "title" : "d"}
	]
}

Example usage:

  • return userrankings[params.userid]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment