Skip to content

Latest commit

 

History

History
134 lines (87 loc) · 2.21 KB

File metadata and controls

134 lines (87 loc) · 2.21 KB

Level 200 - Week 2 - Back End

In the second week of this project you are creating the API for your Video website.

How to read this guide

Below are separate headings for each endpoint. Each of them are separated into the HTTP Request Method type and the route that the endpoint should exist on.

For a recap on about HTTP Request Methods you can read here https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods

For example, for the first endpoint

  • GET is the request method
  • "/" is the route

On Line 8 of server.js you can find an example of the first endpoint that you will need to make.

Project

Before starting this project you should run these commands to install the project

cd server
npm install

to run the server you can use

npm run dev

To confirm your server is running go to

http://127.0.0.1:5000/

in your browser. If the server is running you'll see a message saying

{ "express": "Your Backend Service is Running" }

Sample Solution

Here is an example solution for the Back End:

https://video-rec.herokuapp.com

Endpoints

Your website should have the following four endpoints.

GET "/"

This endpoint is used to return all of the videos

Example Response

See exampleresponse.json

POST "/"

This endpoint is used to add a video to the API.

Both fields - title and url - must be included and be valid for this to succeed.

Note: When a video is added, you must attach a unique ID to so that it can later be deleted

Expected Data

{
  "title": "",
  "url": ""
}

Example Response

If successful:

{
  "id": 523523
}

If not successful

{
  "result": "failure",
  "message": "Video could not be saved"
}

GET "/{id}"

Returns the video with the ID contained within the {id} parameter

Example Response

{
  "id": 1,
  "title": "Never Gonna Give You Up",
  "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "rating": 23
}

DELETE "/{id}"

Deletes the video with the ID container within the {id} parameter

Example Response

If successful:

{}

if not successful:

{
  "result": "failure",
  "message": "Video could not be deleted"
}