Login
Fetch All Stories
Fetch Latest Stories
Submit Story
Fetch Pending Stories
Approve Story
Reject Story
Delete Story
https://bw-refugee-stories.herokuapp.com/
POST Request /api/auth/login
Name | Type | Required | Description |
---|---|---|---|
String | Yes | User's email | |
Password | String | Yes | User's password |
200 Ok
The server will respond with a welcome message and JWT to access restricted routes.
{
"message": "Welcome!",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWJqZWN0IjoxLCJyb2xlIjoiYWRtaW4iLCJpYXQiOjE1NTUxOTExNTIsImV4cCI6MTU1NTI3NzU1Mn0.ZwIH2g1ACpZcH8ast9qdRcutjKkN"
}
400 Bad Request
If you fail to submit an email or password, you will receive a message instructing you to add these.
{
"message": "Please provide an email and password."
}
GET Request /api/stories
200 Ok
The server will respond with an array of all approved stories.
[
{
"id": 4,
"title": "My second story",
"highlight": "we won",
"story": "Some more stuff went down"
},
{
"id": 3,
"title": "My second story",
"highlight": "we won",
"story": "Some more stuff went down"
},
{
"id": 2,
"title": "My third story",
"highlight": "we won",
"story": "Wow hey there"
}
]
GET Request /api/stories/latest
200 Ok
The server will respond with an array of the latest three approved stories.
[
{
"id": 4,
"title": "My second story",
"highlight": "we won",
"story": "Some more stuff went down"
},
{
"id": 3,
"title": "My second story",
"highlight": "we won",
"story": "Some more stuff went down"
},
{
"id": 2,
"title": "My third story",
"highlight": "we won",
"story": "Wow hey there"
}
]
POST Request /api/stories
Name | Type | Required | Description |
---|---|---|---|
Title | String | Yes | User's title |
Story | String | Yes | User's story |
201 Created
The server will respond with the ID of the pending story.
{
"id": 1
}
401 Unauthorized
The server will respond with a message telling you the credentials are incorrect.
{
"message": "Invalid credentials."
}
400 Bad Request
If you fail to submit a title or story, you will receive a message instructing you to add these.
{
"message": "Please provide a title and story to submit."
}
GET Request /api/admin/stories
Name | Required | Description |
---|---|---|
Authorization | Yes | User's JWT |
200 Ok
The server will respond with an array of all pending stories.
[
{
"id": 4,
"title": "My second story",
"story": "Some more stuff went down"
},
{
"id": 3,
"title": "My second story",
"story": "Some more stuff went down"
},
{
"id": 2,
"title": "My third story",
"story": "Wow hey there"
}
]
POST Request /api/admin/stories/approve/:id
Name | Required | Description |
---|---|---|
Authorization | Yes | User's JWT |
Name | Type | Required | Description |
---|---|---|---|
Title | String | Yes | Story title |
Story | String | Yes | Story body |
Highlight | String | Yes | Story highlight |
201 Created
The server will respond with the new ID for the approved story.
{
"newStoryID": 4
}
400 Bad Request
If you fail to submit a title, story and highlight, you will receive a message instructing you to add these.
{
"message": "Please provide a title, story, and highlight to add."
}
DELETE Request /api/admin/stories/reject/:id
Name | Required | Description |
---|---|---|
Authorization | Yes | User's JWT |
200 Ok
The server will respond with a 200 and no body if the story was successfully rejected.
404 Not Found
If the ID cannot be located, the server will provide a message and 404 not found error.
{
"message": "Story could not be located."
}
Deletes an already approved story. Does not operate on pending stories. Please use reject if you need to remove a pending story.
DELETE Request /api/admin/stories/delete/:id
Name | Required | Description |
---|---|---|
Authorization | Yes | User's JWT |
200 Ok
The server will respond with a 200 and no body if the story was successfully deleted.
404 Not Found
If the ID cannot be located, the server will provide a message and 404 not found error.
{
"message": "Story could not be located."
}