In this two part exercise you are tasked with create a REST API for accessing Disney Villain data, complete with test suite.
In the initial commit to this project, you have been provided with data for Disney villains. Your task is to implement an Express driven REST API that allows a user to retrieve this data. Your API should store its data in a database table and implement the routes defined below. Create a branch called part-one-answer
to do this work in.
GET http://localhost:1337/villains
Response
[{
name: 'Captain Hook',
movie: 'Peter Pan',
slug: 'captain-hook',
},
... all other movies
]
GET http://localhost:1337/villains/jafar
Response
{
name: 'Jafar',
movie: 'Aladdin',
slug: 'jafar',
}
POST http://localhost:1337/villains
Body
{
name: 'Red Skull',
movie: 'Captain America: The First Avenger',
slug: 'red-skull',
}
Response
{
id: 21,
name: 'Red Skull',
movie: 'Captain America: The First Avenger',
slug: 'red-skull',
updatedAt: '2020-04-24T13:12:15.656Z',
createdAt: '2020-04-24T13:12:15.656Z'
}
In a branch called part-two-answer
, continuing from your part-one-answer
branch, you are tasked with creating a test suite for your API. You should have tests for each of your controller functions. These tests should cover both happy path as well as error cases.