RESTful API Documentation by Russ, Kal and Sab ©
{
"email": "[email protected] ",
"username": "[email protected] ",
"firstName": "Kal",
"lastName": "Tang",
"location": "Richmond",
"password": "password"
}
{
"accessToken": <accessToken>
}
{
"username": "[email protected] ",
"password": "password"
}
{
"accessToken": <accessToken>
}
{
"message": "Successfully logged out"
}
Get logged in user's communities
Sample Header:
{
authorization: 'Bearer ${token}'
}
{
"user": {
"communities": [
{
"_id": "607492f05d5cbfaa2b8b6406",
"title": "Lansdowne",
"description": "Awesome community near the mall and skytrain",
"location": "Richmond"
},
{
"_id": "6074acc58a2d09ac8741f084",
"title": "Sab's Community",
"description": "Test",
"location": "Richmond"
}
],
"_id": "607492ef5d5cbfaa2b8b6403",
"firstName": "Russ",
"lastName": "Telen"
}
}
Sample Header:
{
authorization: 'Bearer ${token}'
}
{
"user": {
"_id": "607741b3520700f9cb82943c",
"email": "[email protected] ",
"firstName": "Russ",
"lastName": "Telen",
"location": "Richmond",
"avatar": "https://images.unsplash.com/photo-1529111290557-82f6d5c6cf85?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=339&q=80",
"__v": 1
}
}
Sample Header:
{
authorization: 'Bearer ${token}'
}
{
"avatar": <optional url string>
}
{
"message": "Succesfully updated avatar"
}
{
"communities": [
{
"_id": "607492f05d5cbfaa2b8b6406",
"title": "Lansdowne",
"description": "Awesome community near the mall and skytrain",
"location": "Richmond",
"creator": {
"_id": "607492ef5d5cbfaa2b8b6404",
"email": "[email protected] ",
"firstName": "Kal",
"lastName": "Tang"
}
},
{
"_id": "607492f05d5cbfaa2b8b6407",
"title": "Kitsilano",
"description": "Safe community by the beach",
"location": "Vancouver",
"creator": {
"_id": "607492ef5d5cbfaa2b8b6405",
"email": "[email protected] ",
"firstName": "Sab",
"lastName": "Kuah"
}
},
{
"_id": "6074acc58a2d09ac8741f084",
"title": "Sab's Community",
"description": "Test",
"location": "Richmond",
"creator": {
"_id": "607492ef5d5cbfaa2b8b6405",
"email": "[email protected] ",
"firstName": "Sab",
"lastName": "Kuah"
}
}
]
}
Get community by id
{
"community": {
"contents": [
{
"_id": "6070d61ce98bef8863754a07",
"title": "Potholes",
"author": {
"_id": "6070d61be98bef8863754a02",
"email": "[email protected] ",
"firstName": "Russ",
"lastName": "Telen"
},
"__v": 0
},
{
"_id": "6070d61ce98bef8863754a08",
"title": "Missing stop sign",
"author": {
"_id": "6070d61be98bef8863754a04",
"email": "[email protected] ",
"firstName": "Sab",
"lastName": "Kuah"
},
"__v": 0
}
],
"members": [
{
"_id": "6070d61be98bef8863754a03",
"email": "[email protected] ",
"firstName": "Kal",
"lastName": "Tang"
},
{
"_id": "6070d61be98bef8863754a02",
"email": "[email protected] ",
"firstName": "Russ",
"lastName": "Telen"
},
{
"_id": "6070d61be98bef8863754a04",
"email": "[email protected] ",
"firstName": "Sab",
"lastName": "Kuah"
}
],
"_id": "6070d61ce98bef8863754a05",
"title": "Lansdowne",
"description": "Awesome community near the mall and skytrain",
"location": "Richmond",
"geometry": {
"coordinates": [
-123.1139,
49.2609
],
"_id": "607614077ad38dd3f2ba149b",
"type": "Point"
},
"creator": {
"_id": "6070d61be98bef8863754a03",
"email": "[email protected] ",
"firstName": "Kal",
"lastName": "Tang"
},
"__v": 2
}
}
Create a community
Sample Header:
{
authorization: 'Bearer ${token}'
}
{
"title": "5 and Cambie",
"description": "Where the hood at",
"location": "Richmond"
}
{
"message": "Successfully created ${community.title} community"
}
Join a community
/api/communities/:id/join
Sample Header:
{
authorization: 'Bearer ${token}'
}
{
"message": "Successfully joined ${community.title} community"
}
Edit title/description/location of a community
Sample Header:
{
authorization: 'Bearer ${token}'
}
{
"title": "5 and Cambiezzz",
"description": "Where the hood atzzz",
"location": "Richmondzzz"
}
Sample Body if editing only one property:
{
"title": "5 and Cambiezzz",
}
{
"message": "Successfully edited community"
}
Get all posts in a community
/api/communities/:id/posts
{
"posts": [
{
"_id": "607492f15d5cbfaa2b8b640b",
"title": "Potholes",
"description": "I damn near broke my suspension today. Way too many potholes on Arcadia road. Theyre MASSIVE too. This needs to be addressed ASAP",
"date": "2021-04-12T18:35:29.076Z",
"category": "Incident Reports",
"author": {
"_id": "607492ef5d5cbfaa2b8b6403",
"email": "[email protected] ",
"firstName": "Russ",
"lastName": "Telen",
"location": "Richmond"
},
"__v": 0
},
{
"_id": "607492f15d5cbfaa2b8b640c",
"title": "Missing stop sign",
"description": "Somone stole the stop sign @ the corner of Cook rd. Damn hoodlums..",
"date": "2021-04-12T18:35:29.077Z",
"category": "Incident Reports",
"author": {
"_id": "607492ef5d5cbfaa2b8b6405",
"email": "[email protected] ",
"firstName": "Sab",
"lastName": "Kuah",
"location": "Vancouver"
},
"__v": 0
}
]
}
Create a post in a community
/api/communities/:id/posts
Sample Header:
{
authorization: 'Bearer ${token}'
}
{
"title": "First Post !!",
"description": "Weeooooo firs post yay",
"category": "Incident Reports"
}
{
"message": "Succesfully created new post!"
}
Edit title/description/category of a community
/api/communities/:id/posts/:postId
Sample Header:
{
authorization: 'Bearer ${token}'
}
{
"title": "Post title",
"description": "Post description",
"category": "Incident Reports"
}
Sample Body if editing only one property:
{
"title": "Post title"
}
{
"message": "Successfully edited post"
}
COMMENTS
Get all comment in a post
/api/post/:id/comments
{
"comments": [
{
"date": "2021-04-14T19:25:40.985Z",
"_id": "607741b4520700f9cb82944a",
"body": "Aw man i know !! Drove down there the other day and they need to fix that soon!",
"author": {
"_id": "607741b3520700f9cb82943e",
"email": "[email protected] ",
"firstName": "Sab",
"lastName": "Kuah",
"location": "Vancouver",
"avatar": "https://images.unsplash.com/photo-1507331789086-893e9003c0e2?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=334&q=80"
},
"__v": 0
},
{
"date": "2021-04-14T19:25:40.985Z",
"_id": "607741b4520700f9cb82944b",
"body": "^^ right !! sheeesh",
"author": {
"_id": "607741b3520700f9cb82943c",
"email": "[email protected] ",
"firstName": "Russ",
"lastName": "Telen",
"location": "Richmond",
"avatar": "https://images.unsplash.com/photo-1529111290557-82f6d5c6cf85?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=339&q=80"
},
"__v": 0
}
],
"post": "Potholes"
}
Add a comment to a post
/api/post/:id/comments
Sample Header:
{
authorization: 'Bearer ${token}'
}
{
"body": "This is a comment !"
}
{
"message": "Succesfully added comment"
}
Delete a comment
/api/post/:id/comments/:commentId
Sample Header:
{
authorization: 'Bearer ${token}'
}
{
"message": "Succesfully deleted comment"
}