Preview on heroku
Table of Contents
GET /users
200 OK
Content-Type: application/json
{
"users": {
[
{
"id": 1,
"name": "Jean",
"temptationIq": 10,
"games_played": 5
}
]
}
}
GET /users/:id
200 OK
Content-Type: application/json
{
"user": {
"id": 1,
"name": "Jean",
"temptationIq": 10,
"games_played": 5
}
}
POST /users
Content-Type: application/json
{
"name": "Jean"
}
200 OK
Content-Type: application/json
{
"id": 1,
"name": "Jean",
"temptationIq": 100,
"games_played": 0
}
400 INVALID REQUEST
Content-Type: application/json
{
"errors": {
"status": 400,
"title": "Invalid Request",
"Detail": "Name is required"
}
}
GET /temptations?amount=[default: 3]&gender=[male|female|all, default: all]
200 OK
Content-Type: application/json
{
"temptations": [
{
id: 1,
name: 'Sabrina',
imageUrl: 'http://...',
gender: 'female',
iq: 50
},
{
id: 5,
name: 'Sonja',
imageUrl: 'http://...',
gender: 'female',
iq: 100
},
{
id: 2,
name: 'Piet',
imageUrl: 'http://...',
gender: 'male',
iq: 79
}
],
"available_names": ['Jos', 'Maria', ...],
}
POST /users/:id/games
Content-Type: application/json
{
"game": {
"answers": [
{
temptationId: 1,
name: 'Sonja',
iq: 34
},
{
temptationId: 5,
name: 'Sara',
iq: 3
},
{
temptationId: 8,
name: 'Ronny',
iq: 14
}
]
]
}
200 OK
Content-Type: application/json
{
"game": {
"score": 12, # /100
},
"user": {
"id": 1,
"name": "Pol",
"temptationIq": 56,
"gamesPlayed": 1
}
}
400 INVALID REQUEST
Content-Type: application/json
{
"errors": {
"status": 400,
"title": "Invalid Request",
"Detail": ""
}
}
-
git clone git@github.com:icapps/testing-mill.git -
yarn installornpm install -
update
database.jsonwith correct db details -
seed database with temptation data:
sequelize db:migrate --env [development|production] -
npm start
-
Run the database:
docker-compose up -
seed database with temptation data:
sequelize db:migrate --env test -
npm test