Skip to content

Latest commit

 

History

History
267 lines (181 loc) · 2.68 KB

README.md

File metadata and controls

267 lines (181 loc) · 2.68 KB

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: '[email protected]',
  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.