Api for Expat Journal. A web application for storing and sharing user experiences while traveling.
POST /comments
| Name | Type | Description |
|---|---|---|
| authorization | String | The token given to the user at login. |
| Name | Type | Description |
|---|---|---|
| comment | Text | Comment to add to post. |
| post_id | Number | Id of the post to add the comment to. |
| created_at | String | optional Id of the post to add the comment to. |
| updated_at | String | optional Id of the post to add the comment to. |
| likes | Number | optional Number of likes the comment has. |
Post comment example:
const instance = axios.create({
baseURL: 'http://localhost:3200',
timeout: 1000,
headers: {
authorization: "userTokenGoesHere"
}
});
instance.post("/comments", {
comment: "Long string",
post_id: 45,
});
Create post success.
{
"id": 5876,
"created_at": "2019-04-15 01:41:41",
"updated_at": "2019-04-15 01:41:41",
"comment": "Some text here",
"likes": 0,
"user_id": 101,
"post_id": 45
}
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
DELETE /comments/:id
| Name | Type | Description |
|---|---|---|
| authorization | String | The token given to the user at login. |
| Name | Type | Description |
|---|---|---|
| id | Number | Id of the comment to delete. |
Post comment example:
const instance = axios.create({
baseURL: 'http://localhost:3200',
timeout: 1000,
headers: {
authorization: "userTokenGoesHere"
}
});
instance.delete("/comments/798");
Delete post success.
{
message: "Success",
status: 200
}
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
GET /comments/post_id/:id
| Name | Type | Description |
|---|---|---|
| authorization | String | The token given to the user at login. |
| Name | Type | Description |
|---|---|---|
| id | Number | The id of the post you are collecting comments for. |
Get comments example:
const instance = axios.create({
baseURL: 'http://localhost:3200',
timeout: 1000,
headers: {
authorization: "userTokenGoesHere"
}
});
instance.get("/comments/post_id/45");
Posts Data
[
{
"id": 273,
"created_at": "2019-04-14 18:00:08",
"updated_at": "2019-04-15 01:38:18",
"comment": "Autem doloremque est quia sed sequi cumque dolor quaerat recusandae. Autem quia quasi qui in quisquam occaecati exercitationem. Dignissimos ea placeat iusto cumque dolores numquam quidem. Quis quia veritatis odit sed.",
"likes": 0,
"user_id": 30,
"post_id": 45,
"user_name": "Ellen91"
},
{
"id": 274,
"created_at": "2019-04-14 18:27:45",
"updated_at": "2019-04-15 01:38:18",
"comment": "Labore voluptatibus sed asperiores mollitia adipisci doloremque quo. Deleniti itaque voluptatem asperiores rerum sit nemo vitae consequuntur.",
"likes": 0,
"user_id": 95,
"post_id": 45,
"user_name": "Alvena44"
}....
]
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
PUT /comments
| Name | Type | Description |
|---|---|---|
| authorization | String | The token given to the user at login. |
| Name | Type | Description |
|---|---|---|
| id | Number | Post id. |
| post_id | Number | optional Id of the post to add the comment to. |
| comment | Text | optional Comment to add to post. |
| created_at | String | optional Id of the post to add the comment to. |
| updated_at | String | optional Id of the post to add the comment to. |
| likes | Number | optional Number of likes the comment has. |
Post comment example:
const instance = axios.create({
baseURL: 'http://localhost:3200',
timeout: 1000,
headers: {
authorization: "userTokenGoesHere"
}
});
instance.put("/comments", {
id: 273,
likes: 20
});
Create post success.
{
"id": 273,
"created_at": "2019-04-14 18:00:08",
"updated_at": "2019-04-15 01:38:18",
"comment": "Autem doloremque est quia sed sequi cumque dolor quaerat recusandae. Autem quia quasi qui in quisquam occaecati exercitationem. Dignissimos ea placeat iusto cumque dolores numquam quidem. Quis quia veritatis odit sed.",
"likes": 20,
"user_id": 101,
"post_id": 45
}
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
POST /posts/
| Name | Type | Description |
|---|---|---|
| authorization | String | The token given to the user at login. |
| Name | Type | Description |
|---|---|---|
| title | String | The title of the post. |
| description | String | Short description of the post. |
| story | Text | The story of the post. |
| img_url | String | The picture url. |
| city | String | The city the post was taken in. |
| state | String | The state the post was taken in. |
| country | String | The country the post was taken in. |
| likes | Number | optional Number of times the post has been liked. |
| user_profile_img | String | optional The users profile image url. |
| created_at | String | optional Time and date the post was created. |
| updated_at | String | optional Time and date the post was updated. |
Create post example:
const instance = axios.create({
baseURL: 'http://localhost:3200',
timeout: 1000,
headers: {
authorization: "userTokenGoesHere"
}
});
instance.post("/posts", {
title: "Some Title",
description: "Some description",
story: "Lots of text here.",
img_url: "http://SomeUrl.something",
city: "Colorado Springs",
state: "Colorado",
country: "United States of America"
});
Posts Data
{
"id": 2,
"created_at": "2019-04-15T22:40:06.000Z",
"updated_at": "2019-04-16T16:21:40.204Z",
"user_id": 38,
"title": "green leaf trees under blue sky",
"description": "Autem tenetur impedit aut explicabo soluta sint sunt vel corporis.",
"story": "Et sed fugit. In fugit placeat praesentium. Dolores est id facilis itaque quibusdam ut.\n \rQuia dolorum quibusdam adipisci amet unde enim. Itaque a repellendus deleniti voluptatibus aut nisi. Vero consequuntur placeat quod saepe aliquam odit illo. Rem eos omnis quam et. Iste repellendus nihil voluptatem quo.\n \rEt qui repellat rerum ut deserunt assumenda. Dicta libero non. Et et fugiat id eum hic nam itaque. Dolore magni facere maiores. Vel corrupti qui assumenda sapiente consequatur delectus sit. Iste expedita ut officiis.",
"likes": 0,
"img_url": "https://images.unsplash.com/photo-1469827160215-9d29e96e72f4?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjU2NzU3fQ",
"user_profile_img": null,
"country": "Rwanda",
"city": "Bartellton",
"state": "New Mexico",
"user_name": "Maxine.Larson"
}
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
DELETE /posts/:id
| Name | Type | Description |
|---|---|---|
| authorization | String | The token given to the user at login. |
| Name | Type | Description |
|---|---|---|
| id | Number | Post id. |
Delete post example:
const instance = axios.create({
baseURL: 'http://localhost:3200',
timeout: 1000,
headers: {
authorization: "userTokenGoesHere"
}
});
instance.delete("/posts/56");
Update post success
{
message: "Success",
status: 200
}
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
GET /posts/id/:id
| Name | Type | Description |
|---|---|---|
| authorization | String | The token given to the user at login. |
| Name | Type | Description |
|---|---|---|
| id | Number | The id of the post. |
Request example:
axios.post('/posts/id/5', {
headers: {
authorization: "token"
}
});
Posts Data
{
"id": 2,
"created_at": "2019-04-15T22:40:06.000Z",
"updated_at": "2019-04-16T16:21:40.204Z",
"user_id": 38,
"title": "green leaf trees under blue sky",
"description": "Autem tenetur impedit aut explicabo soluta sint sunt vel corporis.",
"story": "Et sed fugit. In fugit placeat praesentium. Dolores est id facilis itaque quibusdam ut.\n \rQuia dolorum quibusdam adipisci amet unde enim. Itaque a repellendus deleniti voluptatibus aut nisi. Vero consequuntur placeat quod saepe aliquam odit illo. Rem eos omnis quam et. Iste repellendus nihil voluptatem quo.\n \rEt qui repellat rerum ut deserunt assumenda. Dicta libero non. Et et fugiat id eum hic nam itaque. Dolore magni facere maiores. Vel corrupti qui assumenda sapiente consequatur delectus sit. Iste expedita ut officiis.",
"likes": 0,
"img_url": "https://images.unsplash.com/photo-1469827160215-9d29e96e72f4?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjU2NzU3fQ",
"user_profile_img": null,
"country": "Rwanda",
"city": "Bartellton",
"state": "New Mexico",
"user_name": "Maxine.Larson"
"comments": [
{
"id": 268,
"created_at": "2019-04-14 00:50:05",
"updated_at": "2019-04-15 01:19:26",
"comment": "Dolor rerum eaque dolore praesentium non dolores. Aspernatur sed sit dolorem cumque omnis exercitationem iure quibusdam eum. Animi enim assumenda porro et aut enim non. Consequatur aut quisquam repellat.",
"user_id": 74,
"post_id": 45,
"user_name": "Ocie_Gusikowski"
}...
]
}
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
GET /posts/:offset
| Name | Type | Description |
|---|---|---|
| authorization | String | The token given to the user at login. |
| Name | Type | Description |
|---|---|---|
| offset | Number | The number to start the posts at. |
Request example:
axios.post('/posts/20', {
headers: {
authorization: "token"
}
});
Posts Data
[
{
"id": 2,
"created_at": "2019-04-15T22:40:06.000Z",
"updated_at": "2019-04-16T16:21:40.204Z",
"user_id": 38,
"title": "green leaf trees under blue sky",
"description": "Autem tenetur impedit aut explicabo soluta sint sunt vel corporis.",
"story": "Et sed fugit. In fugit placeat praesentium. Dolores est id facilis itaque quibusdam ut.\n \rQuia dolorum quibusdam adipisci amet unde enim. Itaque a repellendus deleniti voluptatibus aut nisi. Vero consequuntur placeat quod saepe aliquam odit illo. Rem eos omnis quam et. Iste repellendus nihil voluptatem quo.\n \rEt qui repellat rerum ut deserunt assumenda. Dicta libero non. Et et fugiat id eum hic nam itaque. Dolore magni facere maiores. Vel corrupti qui assumenda sapiente consequatur delectus sit. Iste expedita ut officiis.",
"likes": 0,
"img_url": "https://images.unsplash.com/photo-1469827160215-9d29e96e72f4?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjU2NzU3fQ",
"user_profile_img": null,
"country": "Rwanda",
"city": "Bartellton",
"state": "New Mexico",
"user_name": "Maxine.Larson"
}...
]
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
POST /posts/search
| Name | Type | Description |
|---|---|---|
| authorization | String | The token given to the user at login. |
| Name | Type | Description |
|---|---|---|
| query | String | Search phrase. |
Delete post example:
const instance = axios.create({
baseURL: 'http://localhost:3200',
timeout: 1000,
headers: {
authorization: "userTokenGoesHere"
}
});
instance.post("/posts/search", {
query: "Search phrase"
});
Update post success
{
message: "Success",
status: 200
}
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
PUT /posts/
| Name | Type | Description |
|---|---|---|
| authorization | String | The token given to the user at login. |
| Name | Type | Description |
|---|---|---|
| id | Number | Post id. |
| title | String | optional The title of the post. |
| description | String | optional Short description of the post. |
| story | Text | optional The story of the post. |
| img_url | String | optional The picture url. |
| likes | Number | optional Number of times the post has been liked. |
| user_profile_img | String | optional The users profile image url. |
| created_at | String | optional Time and date the post was created. |
| updated_at | String | optional Time and date the post was updated. |
Update post example:
const instance = axios.create({
baseURL: 'http://localhost:3200',
timeout: 1000,
headers: {
authorization: "userTokenGoesHere"
}
});
instance.put("/posts", {
id: 979,
likes: 25
});
Update post success
{
"id": 979,
"created_at": "2019-04-15 02:09:55",
"updated_at": "2019-04-15 02:09:55",
"user_id": 101,
"title": "Some title",
"description": "ffnkdl;ahijfkdls;a",
"story": "fjdka;fjdinaklf;dfids;",
"likes": 25,
"img_url": "https://www.someurl.com",
"user_profile_img": null,
"user_name": "jeremiah"
}
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
GET /users/:id
| Name | Type | Description |
|---|---|---|
| authorization | String | User auth token. |
| Name | Type | Description |
|---|---|---|
| id | Number | User id. |
Request example:
const request = axios.create({
baseURL: 'http://localhost:3200',
timeout: 1000,
headers: {
authorization: "userTokenGoesHere"
}
});
request.get('/users/11');
User Data
{
"id": 1,
"created_at": "2019-04-13 09:01:42",
"updated_at": "2019-04-13 18:54:22",
"user_name": "Constance36"
}
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
GET /users/posts/:id
| Name | Type | Description |
|---|---|---|
| authorization | String | User auth token. |
| Name | Type | Description |
|---|---|---|
| id | Number | User id. |
Request example:
const request = axios.create({
baseURL: 'http://localhost:3200',
timeout: 1000,
headers: {
authorization: "userTokenGoesHere"
}
});
request.get('/users/posts/5');
Request Success
[
{
"id": 255,
"created_at": "2019-04-15T10:18:46.000Z",
"updated_at": "2019-04-16T01:08:12.937Z",
"user_id": 14,
"title": "aerial photography of buildings",
"description": "Doloremque rerum qui nam similique fugit reiciendis molestias nisi voluptatibus.",
"story": "Possimus dolor qui dolorem laborum cum et maiores sint. Libero debitis nobis pariatur. Vel molestiae labore sint quam et totam porro occaecati. Repellat sequi tempora.\n \rModi ipsum quia delectus omnis qui excepturi sint iure et. Eum voluptas cupiditate et alias. Ut assumenda dicta alias voluptatem corporis est et similique. Cumque sint aut autem voluptas omnis quae. Quia id eligendi vitae omnis. Voluptatem quia tempora quos voluptas eum deleniti.\n \rAt et aliquam natus. Excepturi omnis qui perspiciatis dolores animi dolorem. Voluptates ullam assumenda ut. Consequatur dolores est autem. Et nobis inventore sapiente dignissimos sed.",
"likes": 0,
"img_url": "https://images.unsplash.com/photo-1550604306-50c945776859?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjU2NzU3fQ",
"user_profile_img": null
}...
]
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
POST /users/login
| Name | Type | Description |
|---|---|---|
| user_name | String | Users username |
| password | String | Users password |
Login example:
axios.post('/users/login', {
user_name: "Constance36",
password: "password"
});
Login Success
{
"message": "Welcome jeremiah!",
"user_name": "jeremiah",
"id": 101
"status": 200,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTAxLCJjcmVhdGVkX2F0IjoiMjAxOS0wNC0xMyAyMzowMDoxNSIsInVwZGF0ZWRfYXQiOiIyMDE5LTA0LTEzIDIzOjAwOjE1IiwidXNlcl9uYW1lIjoiamVyZW1pYWgiLCJpYXQiOjE1NTUxOTY0MzAsImV4cCI6MTU1NTI4MjgzMH0.3dY5x5o-OTRPLJwCc2mYSMzjsfdXomtHWvrc14QUvQ4"
}
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
POST /users/register
| Name | Type | Description |
|---|---|---|
| user_name | String | Users username |
| password | String | Users password |
| created_at | String | optional Timestamp the user was created |
| updated_at | String | optional Timestamp the user was last updated. |
Register example:
axios.post('/users/register', {
user_name: "Constance36",
password: "password"
});
Register Success
{
"user": {
"id": 105,
"user_name": "jeremiah18",
"created_at": "2019-04-16T02:00:45.244Z",
"updated_at": "2019-04-16T02:00:45.244Z"
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyIwIjp7ImlkIjoxMDUsInVzZXJfbmFtZSI6ImplcmVtaWFoMTgiLCJjcmVhdGVkX2F0IjoiMjAxOS0wNC0xNlQwMjowMDo0NS4yNDRaIiwidXBkYXRlZF9hdCI6IjIwMTktMDQtMTZUMDI6MDA6NDUuMjQ0WiIsInBhc3N3b3JkIjoiJDJiJDA1JHRBNkljUUYuUTNmODZzLnoxS2VuV2VidzBQNkJicG40RXcvYVNsbUMuMEhyU0pHS2ZOdGpDIn0sImlhdCI6MTU1NTM4MDA0NSwiZXhwIjoxNTU1NDY2NDQ1fQ.NAKsX9kM6z4aGrT_TYNjf_sr-FMib5qgoV_zk3NNNg0"
}
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}
PUT /users
| Name | Type | Description |
|---|---|---|
| authorization | String | User auth token. |
| Name | Type | Description |
|---|---|---|
| id | Number | User id. |
| user_name | String | optional Users username |
| password | String | optional Users password |
Request example:
const request = axios.create({
baseURL: 'http://localhost:3200',
timeout: 1000,
headers: {
authorization: "userTokenGoesHere"
}
});
request.put('/users');
Update Success
{
"message": "Welcome jeremiah!",
"status": 200,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTAxLCJjcmVhdGVkX2F0IjoiMjAxOS0wNC0xMyAyMzowMDoxNSIsInVwZGF0ZWRfYXQiOiIyMDE5LTA0LTEzIDIzOjAwOjE1IiwidXNlcl9uYW1lIjoiamVyZW1pYWgiLCJpYXQiOjE1NTUxOTY0MzAsImV4cCI6MTU1NTI4MjgzMH0.3dY5x5o-OTRPLJwCc2mYSMzjsfdXomtHWvrc14QUvQ4"
}
Error Example:
ERROR XXX
{
"status": xxx,
"message": "Some Error Message"
}