https://refugee-stories-backend-bw.herokuapp.com/
HTTP Method: [GET]
URL: /stories
The returned object will look like:
[
{
"id": 2,
"name": "Zahida",
"title": "Returning home to Syria",
"imageurl": null,
"story": "The destruction was indescribable, and at first I did not recognize my town. When I saw it, it was one of the saddest moments in my life. There was no water, no electricity. We felt that we were in the stone age. But little by little, we made things better.",
"isapproved": true
},
{
"id": 4,
"name": "Anonymous",
"title": "Yaser's Story",
"imageurl": null,
"story": "For two long years Yaser's* five children, Ali*, 15, Achmed*, 14, Hala*, 10, Sedra*, 7 and Aya*, 3, have not been able to go to school or play outside. Violence kept them from living a normal life. There was constant fear of sniper and missile attacks. They learned what type of weapon was being used just by the sound it made.",
"isapproved": true
}
]
HTTP Method: [POST]
URL: /signup
Schema:
| Name | Type | Required | description |
|---|---|---|---|
| username | string | yes | unique username |
| password | string | yes | password |
| admin | boolean | yes | defaults to false |
Example
{
"username": "porter",
"password": "123456"
}
The returned object will be:
{
"username": "porter",
"password": "$2a$09$NGfJ5myE6tvRBqQO.NUaMugbCLTGWa4BOIISq.qFiD1hGdMOUMPFK"
}
HTTP Method: [POST]
URL: /login
Schema:
| Name | Type | Required | description |
|---|---|---|---|
| username | string | yes | unique username |
| password | string | yes | password |
Example
{
"username": "porter",
"password": "123456"
}
The returned object will be:
{
"message": "Welcome!",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWJqZWN0IjozLCJ1c2VybmFtZSI6ImxhbWJkYUFkbWluIiwiYWRtaW4iOjEsImlhdCI6MTU1MjU4NDYzNSwiZXhwIjoxNTUyNjcxMDM1fQ.InIpcAjxIbCSL-Fmfbm2gXOr_JH3l0UlaDYdXnxt1nY"
}
HTTP Method: [POST]
URL: /submitStory
Schema:
| Name | Type | Required | description |
|---|---|---|---|
| name | string | yes | submitter's name |
| title | string | yes | story title |
| imageurl | string | no | url to image |
| story | text | yes | story submission content |
| isapproved | boolean | yes | defaults to false |
Example
{
"title": "This is a test2",
"name": "Tester",
"story": "Hello there. I'm a test story, blah blah blah blah. Blah",
"imageurl": "https://http.cat/",
"isapproved": 0
}
The returned object will be the story's id:
[
13
]
will only render/work if a user has an authorization header
HTTP Method: [GET]
URL: /submissions
The returned object will look like:
[
{
"id": 2,
"name": "Zahida",
"title": "Returning home to Syria",
"imageurl": null,
"story": "The destruction was indescribable, and at first I did not recognize my town. When I saw it, it was one of the saddest moments in my life. There was no water, no electricity. We felt that we were in the stone age. But little by little, we made things better.",
"isapproved": true
},
{
"id": 4,
"name": "Anonymous",
"title": "Yaser's Story",
"imageurl": null,
"story": "For two long years Yaser's* five children, Ali*, 15, Achmed*, 14, Hala*, 10, Sedra*, 7 and Aya*, 3, have not been able to go to school or play outside. Violence kept them from living a normal life. There was constant fear of sniper and missile attacks. They learned what type of weapon was being used just by the sound it made.",
"isapproved": false
}
]
HTTP Method: [PUT]
URL: /submissions/:id
Schema:
| Name | Type | Required | description |
|---|---|---|---|
| name | string | yes | submitter's name |
| title | string | yes | story title |
| imageurl | string | no | url to image |
| story | text | yes | story submission content |
| isapproved | boolean | yes | defaults to false |
Example
{
"title": "This is a test2",
"name": "Tester",
"story": "Hello there. I'm a test story, blah blah blah blah. Blah",
"imageurl": "https://http.cat/",
"isapproved": true
}
The returned object will be the same as the updated fields above
{
"title": "This is a test2",
"name": "Tester",
"story": "Hello there. I'm a test story, blah blah blah blah. Blah",
"imageurl": "https://http.cat/",
"isapproved": true
}
HTTP Method: [DELETE]
URL: /submissions/:id
Schema:
| Name | Type | Required | description |
|---|---|---|---|
| name | string | yes | submitter's name |
| title | string | yes | story title |
| imageurl | string | no | url to image |
| story | text | yes | story submission content |
| isapproved | boolean | yes | defaults to false |
Example
{
"id": 2,
"name": "Moo Chan",
"title": "My Story",
"imageurl": null,
"story": "One day he was in China doing business when he was arrested. He was repatriated and sat in prison for two months before being released. It was then that he truly realized that life was hopeless in North Korea and started to think about joining his resettled family members and good friends in the South. He wanted to be with them more than anything, so he escaped.",
"isapproved": 0
}
The returned object will be the same as the updated fields above
{
"message": "The story has been deleted."
}
Click here to view the Technical Design Document. master