Create a Node.js application that exports RESTful APIs for Movies
Create a Node.js application that exports RESTful APIs for Movies
using this website:https://www.mockaroo.com/, create dummy movies JSON records, each movie record should be structured as following:
id: unique id (uniquely generated), use theuuidpackagehttps://www.npmjs.com/package/uuidtitle: Movie Title (required, min=1, max=128)
year: release year (required, 4 digits, min=1900, max=current year, detect the current year fromdate)
rating: rating value 1 - 5, it can accept a decimal value such as 3.6 (options, default =1)
genres: list of genres for this movie, list can be as an array or has a delimiter, such as pipe "|" or comma "," (optional, default'')
Example:
{
id: 3
title: 'Mission: Impossible Fallout'
year: 2018
rating: 4.5
genres: 'Action|Spy|Thriller'
}
create the following routes:
GET:/: welcome screen that shows the user how to use the APIs
GET:/api/movies: return the full list of the movies (no sorting specified). this API can accept sorting queryStrings:
sort=title|year|ratingorder=asc|descexample:/api/movies?sort=title&order=ascdefault order isascGET:/api/movies/search?q=movieTitle: search for movies matches or partially matches the title
GET:/api/movies/:id: returns a movie byid
POST:/api/movies: insert a new movie submitted in the request body
PUT:/api/movies/:id: updates an existing movieidwith the submitted data in the request bodyDELETE:/api/movies/:id: deletes the movie byid