This is a really simple REST Api for the knoodle project.
In order to make it work correctly you need the latest version of:
- docker-ce
- docker-compose
$ git clone [email protected]:KnpLabs/knoodle-react-api.git
$ cd knoodle-react-api
$ make install-deps
$ make start
This api provides simple endpoints:
Create a new survey. This is an example of json body:
{
"title": "My awesome survey !",
"questions": [
{
"title": "What's your favorite colour ?",
"answers": [
"blue",
"red",
"yellow",
"green",
"pink",
"purple"
]
},
{
"title": "Do you like chocolate ?",
"answers": [
"Yes",
"No",
"It depends on my mood",
"Chocolate ? What's that ?"
]
}
]
}
Return all survey documents. You can filter results with the following filters:
Query String | Values |
---|---|
by | accept popularity , latest or empty (by title asc). |
title | string, the content you need in the title |
offset | integer. Default to 0 |
limit | integer. Default 20 |
Retrieve only one survey document.
Update a document. Same body as POST /surveys
.
Remove an existing survey.
Create an answer for a given survey. Json body must look like:
{
"firstname": "John",
"lastname": "Doe",
"email": "[email protected]",
"answers": {
"<questionId>": "The answer",
"<questionId>": "The other answer"
}
}
You can load some dataset by running:
$ make load-fixtures
This command will load 30 fake surveys to the database.