Skip to content

grupo-6-t12-m3-vilson/json-server-base

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Login

POST /login
POST /signin

Qualquer um desses 2 endpoints pode ser usado para realizar login com um dos usuários cadastrados na lista de "Users"

API

https://api-time-stamp.herokuapp.com

Login usuário

POST /login

{
  "email": "[email protected]",
  "password": "intrutor@$123456"
}

Caso dê tudo certo, a resposta será assim:

FORMATO DA RESPOSTA - STATUS 200

{
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6Im0xQGludHJ1dG9yLmNvbSIsImlhdCI6MTY2MjQyNzgzOCwiZXhwIjoxNjYyNDMxNDM4LCJzdWIiOiIzIn0.yPOWfkHfR1qQl5R0gtUJGZCgj_R4vVgNmFhwieMACG0",
  "user": {
    "email": "[email protected]",
    "name": "Instrutor M1",
    "module": 1,
    "isAdmin": true,
    "id": 3
  }
}

Possíveis erros

Caso o e-mail esteja errado

FORMATO DA RESPOSTA - STATUS 400

{
"Cannot find user"
}

Caso a senha esteja errado

FORMATO DA RESPOSTA - STATUS 400

{
"Incorrect password"
}

Mostrar vídeos

GET /videos

Retorna todos os videos criados, por todos os usuarios

[
  {
    "url": "https://demos-kenzie-academy-brasil.s3.amazonaws.com/mar22/m3/Sprint_1/GMT20220718-123537_Recording_1920x1080.mp4",
    "sprintId": 2,
    "day": "segunda",
    "extra": false,
    "moduleId": 3,
    "userId": 1,
    "created_at": "18/07/22",
    "updated_at": "05/09/22",
    "marks": [
      {
        "id": "1",
        "time_video": "02:30",
        "title": "react-js222"
      },
      {
        "id": 2,
        "time_video": "04:30",
        "title": "json-server"
      }
    ],
    "id": 1
  }

  {
    "url": "https://demos-kenzie-academy-brasil.s3.amazonaws.com/mar22/m3/Sprint_1/GMT20220718-123537_Recording_1920x1080.mp4",
    "sprintId": 2,
    "day": "segunda",
    "extra": false,
    "moduleId": 3,
    "userId": 2,
    "created_at": "18/07/22",
    "updated_at": "05/09/22",
    "marks": [
      {
        "id": "1",
        "time_video": "02:30",
        "title": "react-js222"
      },
      {
        "id": 2,
        "time_video": "04:30",
        "title": "json-server"
      }
    ],
    "id": 2
  }

  {
    "url": "https://demos-kenzie-academy-brasil.s3.amazonaws.com/mar22/m3/Sprint_1/GMT20220718-123537_Recording_1920x1080.mp4",
    "sprintId": 2,
    "day": "segunda",
    "extra": false,
    "moduleId": 3,
    "userId": 3,
    "created_at": "18/07/22",
    "updated_at": "05/09/22",
    "marks": [
      {
        "id": "1",
        "time_video": "02:30",
        "title": "react-js222"
      },
      {
        "id": 2,
        "time_video": "04:30",
        "title": "json-server"
      }
    ],
    "id": 2
  }
]

GET /videos?userId=:userId

Retorna todos os videos criados pelo usuario sem necessidade de autorização

[
  {
    "url": "https://demos-kenzie-academy-brasil.s3.amazonaws.com/mar22/m3/Sprint_1/GMT20220718-123537_Recording_1920x1080.mp4",
    "sprintId": 2,
    "day": "segunda",
    "extra": false,
    "moduleId": 3,
    "userId": 3,
    "created_at": "18/07/22",
    "updated_at": "05/09/22",
    "marks": [
      {
        "id": "1",
        "time_video": "02:30",
        "title": "react-js222"
      },
      {
        "id": 2,
        "time_video": "04:30",
        "title": "json-server"
      }
    ],
    "id": 1
  }

    {
    "url": "https://demos-kenzie-academy-brasil.s3.amazonaws.com/mar22/m3/Sprint_1/GMT20220718-123537_Recording_1920x1080.mp4",
    "sprintId": 2,
    "day": "segunda",
    "extra": false,
    "moduleId": 3,
    "userId": 3,
    "created_at": "18/07/22",
    "updated_at": "05/09/22",
    "marks": [
      {
        "id": "1",
        "time_video": "02:30",
        "title": "react-js222"
      },
      {
        "id": 2,
        "time_video": "04:30",
        "title": "json-server"
      }
    ],
    "id": 2
  }
]

GET /videos?moduleId=3&&sprintId=2

[
  {
    "url": "https://demos-kenzie-academy-brasil.s3.amazonaws.com/mar22/m3/Sprint_1/GMT20220718-123537_Recording_1920x1080.mp4",
    "sprintId": 2,
    "day": "segunda",
    "extra": false,
    "moduleId": 3,
    "userId": 3,
    "created_at": "18/07/22",
    "updated_at": "05/09/22",
    "marks": [
      {
        "id": "1",
        "time_video": "02:30",
        "title": "react-js222"
      },
      {
        "id": 2,
        "time_video": "04:30",
        "title": "json-server"
      }
    ],
    "id": 1
  }
]

Rotas que necessitam de autorização

A partir daqui, todas as rotas necessitam de autenticação

Rotas que necessitam de autorização deve ser informado no cabeçalho da requisição o campo "Authorization", dessa forma:

Authorization: Bearer {token}

Cadastrar vídeos

POST /videos

{
  "url": "https://demos-kenzie-academy-brasil.s3.amazonaws.com/mar22/m3/Sprint_1/GMT20220718-123537_Recording_1920x1080.mp4",
  "sprintId": 1,
  "day": "segunda",
  "extra": false,
  "moduleId": 3,
  "userId": 3,
  "created_at": "18/07/22",
  "updated_at": "05/09/22",
  "marks": [
    {
      "id": "1",
      "time_video": "02:30",
      "title": "react-js222"
    },
    {
      "id": 2,
      "time_video": "04:30",
      "title": "json-server"
    }
  ]
}

FORMATO DA RESPOSTA - STATUS 201

{
  "url": "https://demos-kenzie-academy-brasil.s3.amazonaws.com/mar22/m3/Sprint_1/GMT20220718-123537_Recording_1920x1080.mp4",
  "sprintId": 1,
  "day": "segunda",
  "extra": false,
  "moduleId": 3,
  "userId": 3,
  "created_at": "18/07/22",
  "updated_at": "05/09/22",
  "marks": [
    {
      "id": "1",
      "time_video": "02:30",
      "title": "react-js222"
    },
    {
      "id": 2,
      "time_video": "04:30",
      "title": "json-server"
    }
  ],
  "id": 1
}

PUT /videos/:id

{
   "marks": [
    {
      "id": "1",
      "time_video": "02:50",
      "title": "react-js232"
    },
    {
      "id": 2,
      "time_video": "05:10",
      "title": "json-server"
    }
    ]
}

Caso dê tudo certo, irá retornar

FORMATO DA RESPOSTA - STATUS 200

{
  "url": "https://demos-kenzie-academy-brasil.s3.amazonaws.com/mar22/m3/Sprint_1/GMT20220718-123537_Recording_1920x1080.mp4",
  "sprintId": 1,
  "day": "segunda",
  "extra": false,
  "moduleId": 3,
  "userId": 3,
  "created_at": "18/07/22",
  "updated_at": "06/09/22",
  "marks": [
    {
      "id": "1",
      "time_video": "02:50",
      "title": "react-js232"
    },
    {
      "id": 2,
      "time_video": "05:10",
      "title": "json-server"
    }
  ],
  "id": 1
}

DELETE /videos/:id

{}

Caso dê tudo certo, irá retornar

FORMATO DA RESPOSTA - STATUS 200

{}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%