Skip to content
/ api Public

Collaborative priority ranking - backend. (First pass)

Notifications You must be signed in to change notification settings

ranktank/api

Repository files navigation

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.

models

tank

tank: {
  title: "Tank",
  description: "This is a tank",

  items: [{
    // arbitrary props
  }, {
    ...
  }],

  // user info related to this tank
  users: [{
    user: _userId,

    // history of user in this tank
    actions: [{
      action: 'joined',
      date: new Date()
    }],

    // keeps track of item order per user
    items: [{
      item: _itemId,
      list: 'bank',
      relativePosition: 1000
    }, {
      item: _itemId,
      list: 'rank',
      relativePosition: 2000
    }, {
      ...
    }]
  }, {
    // more users
    ...
  }]
}

users

user: {
  firstName: 'Optimus',
  lastName: 'Prime',
  username: 'tanker1',
  email: 'prime@autobots.com',
  photo: 'url://prime.png',
  ...
}

API endpoints

GET /tanks

Response:

[{tank}, {tank}, ...]

POST /tanks

Request:

{
  title: 'Rank',
  description: 'Tank'
}

Response:

{tank}

GET /tanks/:tankId

Response:

{tank}

PUT /tanks/:tankId

Request:

{
  title: 'New title',
  description: 'New description'
}

Response:

{tank}

DELETE /tanks/:tankId

Yanks a tank of ranks from your bank.

GET /tanks/:tankId/users

Response:

[{tank.user}, {tank.user}, ...]

POST /tanks/:tankId/users

Join a tank.

Request:

Nada

Response:

{tank.user}

DELETE /tanks/:tankId/users/:userId

Leave a tank

GET /tanks/:tankId/users/:userId

Response:

{tank.user}

GET /tanks/:tankId/users/:userId/items

Response:

[{tank.user.item}, {tank.user.item}, ...]

PUT /tanks/:tankId/users/:userId/items/:itemId

Move items between lists or reorder items within a list.

Request:

{
  list: 'rank',
  relativePosition: 1001
}

Response:

{tank.user.item}

GET /tanks/:tankId/ranked

[ranked]

POST /tanks/:tankId/items

Also adds item to each user's item list.

Request:

{
  // anything
}

Response:

{item}

GET /tanks/:tankId/items

[{item}, {item}, ...]

GET /tanks/:tankId/items/:itemId

{item}

PUT /tanks/:tankId/items/:itemId

Request:

{
  // anything
}

Response:

{item}

DELETE /tanks/:tankId/items/:itemId

Also remove item from everyone's userTank

POST /users

Request:

{user}

Response:

{user}

GET | PUT | DELETE /users/:userId

CRUD on users.

About

Collaborative priority ranking - backend. (First pass)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •