In the second week of this project you are creating the API for your Video website.
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.
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" }
Here is an example solution for the Back End:
https://video-rec.herokuapp.com
Your website should have the following four endpoints.
This endpoint is used to return all of the videos
See exampleresponse.json
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
{
"title": "",
"url": ""
}
If successful:
{
"id": 523523
}
If not successful
{
"result": "failure",
"message": "Video could not be saved"
}
Returns the video with the ID contained within the {id}
parameter
{
"id": 1,
"title": "Never Gonna Give You Up",
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"rating": 23
}
Deletes the video with the ID container within the {id}
parameter
If successful:
{}
if not successful:
{
"result": "failure",
"message": "Video could not be deleted"
}