Create a RESTful api that helps to manage a list of famous art. Include scripts to load data and indexes. Provide developer documentation to minimize on-boarding friction.
- Fork the repo
Sign in to your GitHub account and fork the following repo:
https://github.com/jrs-innovation-center/art-api-exam
- Clone your fork
Clone your fork to your local machine and install the project's dependencies.
$ git clone <url>
$ cd art-api-exam
$ npm install
Successfully complete the first 4 steps to receive a grade of 'Meets Expectations'. Complete step 5 to receive a grade of 'Exceeds Expectations'. Complete step 6 to receive a grade of 'Outstanding'
- Using the file named load-data.js, create a program that adds the following paintings into a CouchDB database named
{your first name}Art
. Ex:TripArt
:
Remember to keep your secret safe.
[
{
"_id": "painting_starry_night",
"name": "The Starry Night",
"type": "painting",
"movement": "post-impressionism",
"artist": "Vincent van Gogh",
"yearCreated": 1889,
"museum": {name: "Museum of Modern Art", location: "New York"}
},
{
"_id": "painting_water_lilies_nympheas",
"name": "Water Lilies Nympheas",
"type": "painting",
"movement": "impressionism",
"artist": "Claude Monet",
"yearCreated": 1907,
"museum": {"name": "Art Gallery of Ontario", "location": "Toronto"}
},
{
"_id": "painting_last_supper",
"name": "The Last Supper",
"type": "painting",
"movement": "Renaissance",
"artist": "Leonardo da Vinci",
"yearCreated": 1495,
"museum": {"name": "Santa Maria delle Grazie", "location": "Milan"}
},
{
"_id": "painting_sunday_afternoon_on_the_island_of_la_grande_jatte",
"name": "A Sunday Afternoon on the Island of La Grande Jatte",
"type": "painting",
"movement": "impressionism",
"artist": "Georges Seurat",
"yearCreated": 1884,
"museum": {"name": "Art Institute of Chicago", "location": "Chicago"}
},
{
"_id": "painting_guernica",
"name": "Guernica",
"type": "painting",
"movement": "surrealism",
"artist": "Pablo Picasso",
"yearCreated": 1937,
"museum": {"name": "Museo Nacional Centro de Arte Reina Sofía", "location": "Madrid"}
},
{
"_id": "painting_bal_du_moulin_de_la_galette",
"name": "Bal du moulin de la Galette",
"type": "painting",
"movement": "impressionism",
"artist": "Pierre-Auguste Renoires",
"yearCreated": 1876,
"museum": {"name": "Musée d’Orsay", "location": "Paris"}
}
]
- Within your package.json, create a
load
script that runs your load-data.js program.
- Create a file named named load-index.js to create Mango query indexes, if necessary.
- Within your package.json, create a
loadIndex
script that runs your load-index.js program.
Review the information below and create the described functionality.
-
Create a painting
POST /art/paintings
Creates a painting. The request body must contain a JSON object that represents the painting being created. The request body must include the
name
,movement
,artist
,yearCreated
, andmuseum
fields.Use the
name
field in the creation of the_id
value. DO NOT ALLOW the articles "a" or "the" in the beginning of the name for the primary key value.DO NOT ALLOW the articles "a" or "the" in the beginning of the name for the primary key value. In the example below the name of the painting to create is "The Persistence of Memory". When created the painting should have a primary key value of
_id: "painting_persistence_of_memory"
Sample Request
POST /art/paintings
Sample Request Body JSON Data
{ "name": "The Persistence of Memory", "movement": "surrealism", "artist": "Salvador Dali", "yearCreated": 1931, "museum": {"name": "Musuem of Modern Art", "location": "New York"} }
Sample Response
{ "ok": true, "id": "painting_persistence_of_memory", "rev": "1-c617189487fbe325d01cb7fc74acf45b" }
-
Retrieve a painting
GET /art/paintings/:id
Retrieves a specific painting as identified by the
:id
path parameter.Sample Request
GET /art/paintings/painting_bal_du_moulin_de_la_galette
Sample Response
{ "_id": "painting_bal_du_moulin_de_la_galette", "_rev": "1-c617189487fbe325d01cb7fc74acf45b", "name": "Bal du moulin de la Galette", "type": "painting", "movement": "impressionism", "artist": "Pierre-Auguste Renoires", "yearCreated": 1876, "museum": {"name": "Musée d’Orsay", "location": "Paris"} }
-
Update a painting
PUT /art/paintings/:id
Updates a specific painting as identified by the
:id
path parameter. The request body must contain a JSON object that represents the painting being updated. The request body must include the_id
,_rev
,name
,movement
,artist
,yearCreated
, andmuseum
fields. Themuseum
key value must contain an object that includes aname
andlocation
. Not providing the most recent_rev
value will cause an409 - conflict
error to occur.Sample Request
PUT /art/paintings/painting_bal_du_moulin_de_la_galette
Sample Request Body JSON Data
{ "_id": "painting_bal_du_moulin_de_la_galette", "_rev": "1-c617189487fbe325d01cb7fc74acf45b", "name": "Bal du moulin de la Galette", "type": "painting", "movement": "impressionism", "artist": "Pierre-Auguste Renoires", "yearCreated": 1877, "museum": {"name": "Musée d’Orsay", "location": "Paris"} }
Sample Response
{ "ok": true, "id": "painting_bal_du_moulin_de_la_galette", "rev": "2-7e9b8cac710e70bfe0bef2de7bb3cfdb" }
-
Delete a painting
DELETE /art/paintings/:id
Deletes a specific painting as identified by the
:id
path parameter.Sample Request
DELETE /art/paintings/painting_bal_du_moulin_de_la_galette
Sample Response
{ "ok": true, "id": "painting_bal_du_moulin_de_la_galette", "rev": "3-fdd7fcbc62477372240862772d91c88f" }
-
List paintings with pagination
GET /art/paintings
Returns a collection of paintings sorted by name. An optional
limit
query parameter provides a limit on the number of objects returned. Defaultlimit
value is 5. When used in conjunction withlimit
, an optionallastItem
query parameter provides the ability to return the next page of paintings.Examples
-
GET /art/paintings?limit=2
returns an JSON array of 2 paintings.Sample Response
[ { "_id": "painting_bal_du_moulin_de_la_galette", "_rev": "5-2bac91fbd33b6612e4ea7da0552c91ca", "name": "Bal du moulin de la Galette", "type": "painting", "movement": "impressionism", "artist": "Pierre-Auguste Renoires", "yearCreated": 1876, "museum": { "name": "Musée d’Orsay", "location": "Paris" } }, { "_id": "painting_guernica", "_rev": "5-a8b803395d7cb6154f63c627571a5575", "name": "Guernica", "type": "painting", "movement": "surrealism", "artist": "Pablo Picasso", "yearCreated": 1937, "museum": { "name": "Museo Nacional Centro de Arte Reina Sofía", "location": "Madrid" } } ]
-
GET /art/paintings?limit=2&lastItem=painting_guernica
to get the next page of results:Sample Response
[ { "_id": "painting_last_supper", "_rev": "3-418af3c02f63725a2bd7941afe0cc3c6", "name": "The Last Supper", "type": "painting", "movement": "Renaissance", "artist": "Leonardo da Vinci", "yearCreated": 1495, "museum": { "name": "Santa Maria delle Grazie", "location": "Milan" } }, { "_id": "painting_starry_night", "_rev": "3-5e8b713e1644779ebbb29c539166bd81", "name": "The Starry Night", "type": "painting", "movement": "post-impressionism", "artist": "Vincent van Gogh", "yearCreated": 1889, "museum": { "name": "Museum of Modern Art", "location": "New York" } } ]
-
Create developer on-boarding instructions by creating a README.md file. Include the following sections:
Within the Getting Started section provide guidance on how to:
- Clone your repo
- Install dependencies
- Establish environment variables
- Load data
- Load indexes
- Start the API
-
Create a
filter
query parameter on theGET /art/paintings
endpoint to provide flexible search capability. -
Provide the ability to filter paintings by name, movement, artist and year created.
-
The
filter
query parameter may be used in conjunction withlimit
but not withlastItem
.Paintings may not be filtered and paginated at the same time.
Example
-
Filter by movement and limit to five paintings
GET /art/paintings?filter=movement:surrealism&limit=5
Sample Results
[ { "_id": "painting_guernica", "_rev": "1-ccd60fb0ca42d879d048f083b95cfdcb", "name": "Guernica", "type": "painting", "movement": "surrealism", "artist": "Pablo Picasso", "yearCreated": 1937, "museum": { "name": "Museo Nacional Centro de Arte Reina Sofía", "location": "Madrid" } } ]
-
-
Enhance the existing
filter
query parameter on theGET /art/paintings
endpoint by addingeq
(equals),gt
(greater than),gte
(greater than equal to) ,lt
(less than),lte
(less than equal to) comparison operators within your filter. -
The
filter
query parameter may be used in conjunction withlimit
but not withlastItem
.
Paintings may not be filtered and paginated at the same time.
Examples
-
Filter paintings created after 1930. Limit results to 5 paintings
GET /art/paintings?filter=yearCreated:gt:1930&limit=5
Sample Results
[ { "_id": "painting_guernica", "_rev": "1-ccd60fb0ca42d879d048f083b95cfdcb", "name": "Guernica", "type": "painting", "movement": "surrealism", "artist": "Pablo Picasso", "yearCreated": 1937, "museum": { "name": "Museo Nacional Centro de Arte Reina Sofía", "location": "Madrid" } } ]
-
Filter by artists greater or equal to Pablo Picasso.
GET /art/paintings?filter=artist:gte:Pablo Picasso
Sample Results
[ { "_id": "painting_guernica", "_rev": "1-ccd60fb0ca42d879d048f083b95cfdcb", "name": "Guernica", "type": "painting", "movement": "surrealism", "artist": "Pablo Picasso", "yearCreated": 1937, "museum": { "name": "Museo Nacional Centro de Arte Reina Sofía", "location": "Madrid" } }, { "_id": "painting_bal_du_moulin_de_la_galette", "name": "Bal du moulin de la Galette", "type": "painting", "movement": "impressionism", "artist": "Pierre-Auguste Renoires", "yearCreated": 1876, "museum": {"name": "Musée d’Orsay", "location": "Paris"} }, { "_id": "painting_starry_night", "name": "The Starry Night", "type": "painting", "movement": "post-impressionism", "artist": "Vincent van Gogh", "yearCreated": 1889, "museum": {"name": "Museum of Modern Art", "location": "New York"} } ]