Models
Post
{
title: String,
url: String,
user: 'username',
score: Number,
date: Number,
content: String,
type: String,
tags: Array('postTag')
}
PostTag
postTag: {
tag: 'tag',
post: 'post',
score: Number
}
PostTagVote
postTagVote: {
tag: 'tag',
post: 'post',
user: 'username',
score: Number
}
Tag
tag: {
name: String,
count: Number
}
Comment
comment: {
id: String
time: Number,
post: 'post',
parent: 'comment'
childCount: Number,
content: String,
user: 'username',
upvotes: Number,
downvotes: Number,
threadUpvotes: Number,
threadDownvotes: Number
}
CommentVote
commentVote: {
comment: 'comment',
post: 'post',
user: 'user',
date: Date,
positive: Boolean
}
Posts API
GET /posts
Returns 100 posts.
Parameters
Offsets the responses by a set number.
Returns posts sorted by a particular algorithm.
-
popular default
Posts are sorted by score, within a time span between now and the requesting user's last login, or 24 hours, whichever is longer.
-
new
Posts are sorted by date. Newest first.
-
top
Posts are sorted by score. Highest first.
Only returns posts that were created within a specific time period.
-
all default
No time constraints.
-
day
Only returns posts created in the last day.
-
week
Only returns posts created in the last week.
-
month
Only returns posts created in the last month.
-
year
Only returns posts created in the last year.
Only returns results that match a specific tag. Multiple tags can be listed by separating tags with a +. If more than one tag is listed, it will return posts that match any of the tags. As an example:
/posts?tag=funny+wtf
will return 100 posts that either have a tag of funny or wtf.
Only returns results posts that were made by a specific user.
Requirements
-
Authentication
With no auth, should return401 Unauthorized
Example response
{
posts: [
{
"title": "test post",
"url": "this_is_crazy",
"user": "wombodombo",
"score": 148,
"time": "1577171754000",
"content": "This is a cool photo I took of my cat way back when",
"type": "image",
"tags": [
{
"tag": "funny",
"score": 10,
},
{
"tag": "meme",
"score": 7,
},
{
"tag": "image",
"score": 4,
}
]
},
// ...etc
]
}
GET /post/view/:url
Returns the data for a single post, referenced by its url. The date for the tags is the date the postTag association was first created.
Requirements
None. Should be available publicly
Example response
{
"title": "test post",
"url": "this_is_crazy",
"user": "wombodombo",
"score": 148,
"time": "1577171754000",
"content": "This is a cool photo I took of my cat way back when",
"type": "image",
"tags": [
{
"tag": "funny",
"score": 10,
},
{
"tag": "meme",
"score": 7,
},
{
"tag": "image",
"score": 4,
}
]
}
POST /post/create
Accepts a JSON payload to create a new post in the database
Requirements
Authentication
With no auth, should return401 Unauthorized
Example payload
{
"title": "My Cool Post!",
"url": "my-neato-post-wow",
"content": "This is the long form content for this post...",
"type": "blog"
}
Example response
{
"title": "My Cool Post!",
"user": "lapubell",
"time": "1577171754000",
"url": "my-neto-post-wow",
"tags": []
}
GET /post/url-is-available/:url
Returns a boolean based on if the requested URL is available
Requirements
None. Should be available publicly
Example response
true
Tags API
GET /tags
Should return 100 tags, sorted by number of postTags for that tag that have been created between now and the requesting user's last login, or one month, whichever is longer. The number of postTags for that tag should be populated into the "count" field.
Requirements
-
Authentication
With no auth, should return401 Unauthorized
Parameters
Offsets the responses by a set number.
Returns tags sorted by a particular algorithm.
-
top default
Tags are sorted by count.
-
new
Tags are sorted by date. Newest first.
Only returns tags that were created within a specific time period.
-
all default
No time constraints.
-
day
Only returns tags created in the last day.
-
week
Only returns tags created in the last week.
-
month
Only returns tags created in the last month.
-
year
Only returns tags created in the last year.
Example response
{
"tags": [
{
"tag": "art",
"count": 4849,
},
{
"tag": "funny",
"count": 382,
},
// ...etc
}
]
}
PostTags API
POST/posttag/create
Adds a tag to a post.
Requirements
-
Authentication
With no auth, should return401 Unauthorized
Example payload
{
"post": "a-cool-painting",
"tag": "art",
}
Example response
{
"post": "a-cool-painting",
"tag": "art",
"score": 1
}
POST/posttag/add-vote
Adds a vote for a posttag.
Requirements
-
Authentication
With no auth, should return401 Unauthorized
Example payload
{
"post": "a-cool-painting",
"tag": "art",
}
Example response
{
"post": "a-cool-painting",
"tag": "art",
"score": 41
}
POST/posttag/remove-vote
Removes an existing vote for a posttag. If it is the only vote for it, this action also removes the posttag.
Requirements
-
Authentication
With no auth, should return401 Unauthorized
Example payload
{
"post": "a-cool-painting",
"tag": "art",
}
Example response
{
"post": "a-cool-painting",
"tag": "art",
"score": 40
}
Comments API
GET /comments/post/:post
Should return 100 comments for a specific post.
Parameters
Offsets the responses by a set number.
Returns comments sorted by a particular algorithm.
-
popular default
Comments are sorted by threadUpvotes. Highest first.
-
new
Comments are sorted by date. Newest first.
Example response
{
"comments": [
{
"id": "YPGpbT",
"time": "1577171754000",
"post": "this_is_crazy",
"parent": null,
"childCount": 4,
"content": "I really like this",
"user": "bojackson",
"upvotes": 144,
"downvotes": 38,
"threadUpvotes": 188,
"threadDownvotes": 22
},
{
"id": "qc33cG",
"time": "1577171754000",
"post": "this_is_crazy",
"parent": null,
"childCount": 0,
"content": "How neat!",
"user": "mamadisco",
"upvotes": 42,
"downvotes": 7,
"threadUpvotes": 42,
"threadDownvotes": 7
},
...etc
]
}
GET /comments/user/:user
Should return 100 comments for a specific user.
Parameters
Offsets the responses by a set number.
Returns comments sorted by a particular algorithm.
-
popular default
Comments are sorted by (upvotes - downvotes). Highest first.
-
new
Comments are sorted by date. Newest first.
Example response
{
"comments": [
{
"id": "YPGpbT",
"time": "1577171754000",
"post": "this_is_crazy",
"parent": null,
"childCount": 4,
"content": "I really like this",
"user": "jjcm",
"upvotes": 144,
"downvotes": 38,
"threadUpvotes": 188,
"threadDownvotes": 22
},
{
"id": "qc33cG",
"time": "1577171754000",
"post": "rickroll",
"parent": null,
"childCount": 0,
"content": "my fav song",
"user": "jjcm",
"upvotes": 42,
"downvotes": 7,
"threadUpvotes": 42,
"threadDownvotes": 7
},
...etc
]
}
GET /comments/comment/:comment
Should return 100 replies for a specific comment.
Parameters
Offsets the responses by a set number.
Returns comments sorted by a particular algorithm.
-
popular default
Comments are sorted by threadUpvotes. Highest first.
-
new
Comments are sorted by date. Newest first.
Example response
{
"comments": [
{
"id": "YPGpbT",
"time": "1577171754000",
"post": "this_is_crazy",
"parent": "GhB83c",
"childCount": 4,
"content": "I really like this",
"user": "bojackson",
"upvotes": 144,
"downvotes": 38,
"threadUpvotes": 188,
"threadDownvotes": 22
},
{
"id": "qc33cG",
"time": "1577171754000",
"post": "this_is_crazy",
"parent": "GhB83c",
"childCount": 0,
"content": "How neat!",
"user": "mamadisco",
"upvotes": 42,
"downvotes": 7,
"threadUpvotes": 42,
"threadDownvotes": 7
},
...etc
]
}
POST /comment/create
Allows the creation of a comment on a specific post. Can either be a top level comment or a reply to an existing comment.
Example payload
{
post: "this_is_crazy",
parent: null,
content: "Hey this is a comment!",
}
Example response
{
"id": "qc33cG",
"time": "1577171754000",
"post": "this_is_crazy",
"parent": null,
"childCount": 0,
"content": "How neat!",
"user": "jjcm",
"upvotes": 0,
"downvotes": 0,
"threadUpvotes": 0,
"threadDownvotes": 0
}
POST /comment/update/:comment
Allows for the update of a specific comment. Comment must be made by the user updating it.
Example payload
{
post: "this_is_crazy",
parent: null,
content: "Hey this is a *cool* comment!",
}
Example response
{
"id": "qc33cG",
"time": "1577171754000",
"post": "this_is_crazy",
"parent": null,
"childCount": 0,
"content": "How neat!",
"user": "jjcm",
"upvotes": 0,
"downvotes": 0,
"threadUpvotes": 0,
"threadDownvotes": 0
}
POST /comment/delete/:comment
Deletes a specific comment. Comment must be made by the user deleting it.
Example response
true
User API
POST /user/login
Logs the user in. Returns a JWT.
Example payload
{
"email": "jjcm@non.io",
"password": "hunter2"
}
Example response
{
"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFzZGZAYXNkZi5jb20iLCJleHBpcmVzQXQiOjE1ODMxNDc1NDh9.okbK22xZYZFk19K_NwLd7g48mxQZfWR5filMadonSe8",
"username":"jjcm"
}
POST /user/register
Logs the user in. Returns a JWT.
Example payload
{
"username": "jjcm",
"email": "jjcm@non.io",
"password": "hunter2",
"contribution": "5",
"creditCardName": "Jake Miller",
"creditCardNumber": "1111-2222-3333-4444",
"creditCardExp": "2130-01-01",
"creditCardCCV": "420"
}
Example response
{
"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFzZGZAYXNkZi5jb20iLCJleHBpcmVzQXQiOjE1ODMxNDc1NDh9.okbK22xZYZFk19K_NwLd7g48mxQZfWR5filMadonSe8",
"username":"jjcm"
}
GET /user/username-is-available/:username
Returns a boolean based on if the requested username is available
Requirements
None. Should be available publicly
Example response
true