about api specification - N4SJAMK/teamboard-meta GitHub Wiki

About API Specification

This document is about the proposed API specification, that should be implemented after Q3. This is not final.

Authentication

teamboard-auth

Authentication is a service that is used by users to generate access-tokens and authenticate into the system.

MongoDB users collection structure:

{
	"_id": "ObjectId",

	"email":    "user_email",
	"username": "user_username",

	"password": "bcrypt(user_password)",

	"created_at": "Time"
}

MongoDB tokens collection structure:

{
	"_id":        "ObjectId",
	"user_id":    "ObjectId",
	"created_at": "Time",

	"secret": "access_token"
}

It offers the following methods:

  • POST /login
{
	"email":    "[email protected]",
	"password": "meritaehti"
}

Sets the x-access-token header.

  • POST /register
{
	"email":    "[email protected]",
	"password": "meritaehti"
}
{
	"_id":        "ObjectId",
	"email":      "[email protected]",
	"created_at": "Time"
}

API

teamboard-api

API is a RESTful service that the client (currently) uses. In the future, API should be a separate service that is not necessarily used by the primary client but instead serves as a gateway for 3rd parties.

MongoDB boards collection structure:

{
	"_id":        "ObjectId",
	"created_by": "ObjectId",
	"created_at": "Time",

	"name":        "board_name",
	"description": "board_description",

	"size": {
		"width":  8,
		"height": 8,
	},

	"background": "background_id",

	"members": [
		{
			"role":         "admin|member",
			"user_id":      "ObjectId",
			"member_since": "Time"
		},
	]
}

MongoDB tickets collection structure:

{
	"_id":        "ObjectId",
	"board_id":   "ObjectId",
	"created_by": "ObjectId",
	"created_at": "Time",

	"color":   "#FFFFFF",
	"heading": "kikkelis",
	"content": "kokkelis",

	"position": {
		"x": 0,
		"y": 0,
		"z": 0
	},

	"linked_users": [
		"ObjectId",
	],

	"linked_boards": [
		"ObjectId",
	],

	"linked_tickets": [
		"ObjectId",
	]
}

It offers the following methods:

  • POST /boards
{
	"name":        "board_name",
	"description": "board_description",

	"size": {
		"width":  8,
		"height": 8,
	}
}
{
	"_id":        "ObjectId",
	"created_by": "ObjectId",
	"created_at": "Time",

	"name":        "board_name",
	"description": "board_description",

	"size": {
		"width":  8,
		"height": 8,
	},

	"background": "background_id"
}

Creating a board sets the creating user as admin.

  • GET /boards
  • GET /boards/:board_id
[{
	"_id":        "ObjectId",
	"created_by": "ObjectId",
	"created_at": "Time",

	"name":        "board_name",
	"description": "board_description",

	"size": {
		"width":  8,
		"height": 8,
	},

	"background": "background_id"
}]
  • PUT /boards/:board_id
{
	"name":        "new_board_name",
	"description": "new_board_description",
	"background":  "new_background_id"
}
{
	"_id":        "ObjectId",
	"created_by": "ObjectId",
	"created_at": "Time",

	"name":        "new_board_name",
	"description": "new_board_description",

	"size": {
		"width":  8,
		"height": 8,
	},

	"background": "new_background_id"
}
  • PUT /boards/:board_id/size
{
	"width":  9,
	"height": 16
}
{
	"_id":        "ObjectId",
	"created_by": "ObjectId",
	"created_at": "Time",

	"name":        "new_board_name",
	"description": "new_board_description",

	"size": {
		"width":  9,
		"height": 16,
	},

	"background": "new_background_id"
}
  • DELETE /boards/:board_id
{
	"_id":        "ObjectId",
	"created_by": "ObjectId",
	"created_at": "Time",

	"name":        "new_board_name",
	"description": "new_board_description",

	"size": {
		"width":  9,
		"height": 16,
	},

	"background": "new_background_id"
}
  • POST /boards/:board_id/members
{
	"role":    "member",
	"user_id": "ObjectId"
}
{
	"role":         "member",
	"user_id":      "ObjectId",
	"member_since": "Time"
}
  • GET /boards/:board_id/members
  • GET /boards/:board_id/members/:user_id
[{
	"role":         "member|admin",
	"user_id":      "ObjectId",
	"member_since": "Time"
}]
  • PUT /boards/:board_id/members/:user_id
{
	"role": "admin"
}
{
	"role":         "admin",
	"user_id":      "ObjectId",
	"member_since": "Time"
}
  • DELETE /boards/:board_id/members/:user_id
{
	"role":         "admin",
	"user_id":      "ObjectId",
	"member_since": "Time"
}
  • POST /boards/:board_id/tickets
{
	"color":   "#FFFFFF",
	"heading": "kikkelis",
	"content": "kokkelis",

	"position": {
		"x": 0,
		"y": 0,
		"z": 0
	},
}
{
	"_id":        "ObjectId",
	"created_by": "ObjectId",
	"created_at": "Time",

	"color":   "#FFFFFF",
	"heading": "kikkelis",
	"content": "kokkelis",

	"position": {
		"x": 0,
		"y": 0,
		"z": 0
	},

	"linked_users":   [ ],
	"linked_boards":  [ ],
	"linked_tickets": [ ]
}
  • GET /boards/:board_id/tickets
  • GET /boards/:board_id/tickets/:ticket_id
[{
	"_id":        "ObjectId",
	"created_by": "ObjectId",
	"created_at": "Time",

	"color":   "#FFFFFF",
	"heading": "kikkelis",
	"content": "kokkelis",

	"position": {
		"x": 0,
		"y": 0,
		"z": 0
	},

	"linked_users":   [ ],
	"linked_boards":  [ ],
	"linked_tickets": [ ]
}]
  • PUT /boards/:board_id/tickets/:ticket_id
{
	"color":   "#5FBFAA",
	"heading": "muna",
	"content": "koisoo"
}
{
	"_id":        "ObjectId",
	"created_by": "ObjectId",
	"created_at": "Time",

	"color":   "#5FBFAA",
	"heading": "muna",
	"content": "koisoo",

	"position": {
		"x": 0,
		"y": 0,
		"z": 0
	},

	"linked_users":   [ ],
	"linked_boards":  [ ],
	"linked_tickets": [ ]
}
  • PUT /boards/:board_id/tickets/:ticket_id/position
{
	"x": 23,
	"y": 128,
	"z": 3
}
{
	"_id":        "ObjectId",
	"created_by": "ObjectId",
	"created_at": "Time",

	"color":   "#5FBFAA",
	"heading": "muna",
	"content": "koisoo",

	"position": {
		"x": 23,
		"y": 128,
		"z": 3
	},

	"linked_users":   [ ],
	"linked_boards":  [ ],
	"linked_tickets": [ ]
}
  • DELETE /boards/:board_id/tickets/:ticket_id
{
	"_id":        "ObjectId",
	"created_by": "ObjectId",
	"created_at": "Time",

	"color":   "#5FBFAA",
	"heading": "muna",
	"content": "koisoo",

	"position": {
		"x": 23,
		"y": 128,
		"z": 3
	},

	"linked_users":   [ ],
	"linked_boards":  [ ],
	"linked_tickets": [ ]
}
  • POST /boards/:board_id/tickets/:ticket_id/linked_(users|boards|tickets)
{
	"user_id|board_id|ticket_id": "ObjectId"
}
[
	"ObjectId",
]

Returns the modified linked_(users|boards|tickets) array

  • DELETE /boards/:board_id/tickets/:ticket_id/linked_(users|boards|tickets)/:id
[ ]

Returns the modified linked_(users|boards|tickets) array

  • GET /users
  • GET /users/:user_id
[{
	"_id":        "ObjectId",
	"created_at": "Time",

	"email":    "user_email",
	"username": "user_username"
}]
⚠️ **GitHub.com Fallback** ⚠️