Skip to content

Build-Week-30Before30/BackEnd

Repository files navigation

BackEnd

https://buildweek30before30.herokuapp.com/api

You must create an instance of axios with axios.create and have the withCredentials configuration property set to true.

Example Setup

const api = axios.create({
  baseURL: 'https://buildweek30before30.herokuapp.com/api',
  withCredentials: true,
});

api.post('/auth/register', { username: 'goodusername', password: 'goodpassword' })
  .then(response => console.log(response.data))

Authentication

Endpoint Method Notes
/auth/register POST Expects { username, password }.
  • 201 if registration was successful.
    • Responds with { id }.
  • 400 if required information is missing.
    • Responds with { message }.
  • 409 if the username is already taken.
    • Responds with { message }.
/auth/login POST In your axios' post call, add a 3rd parameter, which is an object that contains an auth object. That auth object should contain username and password.
  • 200 if login was successful.
  • 404 if the user was not found.
    • Responds with { message }.
  • 401 if the password is incorrect.
    • Responds with { message }.
/auth/logout GET
  • 200 on successful logout.

Lists

Example List

{
  "id": 9,
  "user_id": 1,
  "name": "Cool list",
  "description": "Do it before you die",
  "deadline": null,
  "is_private": true,
  "created_by": "test",
  "comments": [
    {
      "id": 3,
      "user_id": 1,
      "content": "Hello worlasdasdd!",
      "created_by": "test",
      "created_at": "2019-10-22T21:29:01.718Z",
      "updated_at": "2019-10-22T21:29:01.718Z"
    }
  ],
  "items": [
    {
      "id": 2,
      "list_id": 9,
      "name": "Test item",
      "description": "Test description",
      "deadline": null,
      "completed": false
    }
  ]
}

Example Item

{
  "id": 3,
  "list_id": 9,
  "name": "Test item",
  "description": "Test description",
  "deadline": null,
  "completed": false
}

Example Comment

{
  "id": 3,
  "user_id": 1,
  "content": "Hello worlasdasdd!",
  "created_by": "test",
  "created_at": "2019-10-22T21:29:01.718Z",
  "updated_at": "2019-10-22T21:29:01.718Z"
}
Endpoint Method Notes
/lists GET
  • 200 with an array of all lists.
/lists POST
  • 201 if creation was successful.
    • Responds with the created list.
/lists/:id PUT
  • 200 if the list with the specified id was updated.
    • Responds with the updated list.
  • 404 if the list with the specified id could not be found.
    • Responds with { message } .
/lists/:id GET
  • 200 if the list with the specified id was found.
    • Responds with the list.
  • 404 if the list with the specified id could not be found.
    • Responds with { message } .
/lists/:id DELETE
  • 204 if the list with the specified id was deleted.
  • 404 if the list with the specified id could not be found.
    • Responds with { message } .
/lists/:id/items POST Expects { name, description, completed, deadline (optional) }.
  • 201 if the item was created.
    • Responds with the new item.
  • 404 if the list with the specified id could not be found.
    • Responds with { message } .
/lists/items/:itemId DELETE
  • 204 if the item was deleted.
  • 404 if the item with the specified itemId could not be found.
    • Responds with { message } .
/lists/items/:itemId PUT Expects { name, description, completed, deadline (optional) }.
  • 200 if the item was updated.
    • Responds with the new item.
  • 404 if the item with the specified itemId could not be found.
    • Responds with { message } .
/lists/:id/comments POST Expects { content }.
  • 201 if the comment was created.
    • Responds with the new comment.
  • 404 if the list with the specified id could not be found.
    • Responds with { message } .
/lists/comments/:commentId DELETE
  • 204 if the comment was deleted.
  • 404 if the comment with the specified commentId could not be found.
    • Responds with { message } .
/lists/comments/:commentId PUT Expects { content }.
  • 200 if the comment was updated.
    • Responds with the new comment.
  • 404 if the comment with the specified commentId could not be found.
    • Responds with { message } .

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •