April 2019
OneFeed is a web app that combines multiple social media platforms into a single, unique feed.
It is possible to log in to Twitter, Instagram, YouTube, and Tumblr. The user is then given the option to enable and disable certain feeds, and is allowed to select subreddits from Reddits. Content from these feeds is then shown on OneFeed (note that the Tumblr feed is disabled due to current restrictions regarding usage of their API). If a user attempts to access a feed without being authenticated, a 403 error and a JSON response is returned.
Users can submit text posts and jokes to the platform, which are retrievable through the API and are displayed to both the user and others on their feeds. The jokes and posts entities are related to another entity, authors, which contains those who have contributed to the site thus far.
If the server disconnects and the user attempts to access a server-side resource (e.g. jokes, posts), an error is shown on the user's screen.
Cloud deployment: https://one-feed-app.herokuapp.com/
To run both jest and eslint, execute the following:
npm test
To only run eslint, execute the following:
npm run pretest
In addition to the "eslint:recommended" tests, 31 additional tests are specified in .eslintrc.js
.
Note that if the following dependencies are not installed, the additional tests will result in an error when running either test or run pretest:
- eslint
- eslint-config-standard
- eslint-plugin-standard
- eslint-plugin-promise
- eslint-plugin-import
- eslint-plugin-node
During testing, nock is used to intercept external requests and return predefined responses when appropriate; no external requests are made during testing. The object containing the user's session is also mocked when required, and the mocking is the combination of this code in app.js along with nock and the tests in app.test.js. Multiple remote web services are used, which are mocked in tests (per the above).
OneFeed can be installed with the following command (when in the directory):
npm install
The server can be started with the following command:
npm start
This allows the site to be accessed at http://127.0.0.1:8090.
Additionally, a cloud deployment of the site exists, located at https://one-feed-app.herokuapp.com/ (there may be a small delay in loading this page).
Returns an array of posts from a given subreddit after a certain post id.
This method takes two parameters, subreddit
(required), which indicates the subreddit to retrieve data from, and after
(optional), the post id in the subreddit to show posts after.
GET http://127.0.0.1:8090/reddit?subreddit=rarepuppers
[
{
data: {
"subreddit": "rarepuppers",
"id": "280219328"
}
},
{
data: {
"subreddit": "rarepuppers",
"id": "3219"
}
}
]
Returns an array of a list of subreddits starting in a given search term.
This method takes one parameter, search
(required), indicating the subreddit to search for.
GET http://127.0.0.1:8090/redditSubreddits?search=dogs
[
"dogs",
"dogswithjobs",
"DogShowerThoughts",
"dogs_getting_dogs",
"dogswearinghats",
"DogsMirin",
"dogsonroofs",
"dogswitheyebrows"
]
Check whether the Reddit bearer token has expired by comparing the expiry time to the current time.
This method takes no parameters and returns an object indicating whether the token has expired.
GET http://127.0.0.1:8090/redditTokenExpired
{
"expired": false,
}
Obtain a new application bearer token from Reddit for the server to use.
This method takes no parameters and returns an object indicating whether the token has been obtained.
GET http://127.0.0.1:8090/redditToken
{
"token": true
}
Check whether authenticated user is logged in to Twitter.
This method takes no parameters and returns an object indicating whether the user is logged in.
GET http://127.0.0.1:8090/twitter/isLoggedIn
{
"auth": true,
}
Endpoint used for handling passport logins to Twitter. Redirects to Twitter for login.
Endpoint used for handling passport logins to Twitter. Allows the response by Twitter to be noted and redirected.
Returns an array of objects of timeline items from Twitter. If the user is not logged in, returns a 403 authentication error.
GET http://127.0.0.1:8090/twitter/timeline
[
{
"text": "content",
"user": {
...
},
url: "https://twitter.com/",
...
},
{
"text": "content too",
"user": {
...
},
url: "https://twitter.com/",
...
}
]
Check whether authenticated user is logged in to YouTube.
This method takes no parameters and returns an object indicating whether the user is logged in.
GET http://127.0.0.1:8090/youtube/isLoggedIn
{
"auth": false,
}
Endpoint used for handling passport logins to YouTube. Redirects to YouTube for login.
Endpoint used for handling passport logins to YouTube. Allows the response by YouTube to be noted and redirected.
Returns an array of objects of popular videos from YouTube. If the user is not logged in, returns a 403 authentication error.
GET http://127.0.0.1:8090/youtube/popular
[
{
"from": "youtube",
"snippet": {
"title": "title string",
...
},
...
},
{
"from": "youtube",
"snippet": {
"title": "title string too",
...
},
...
}
]
Check whether authenticated user is logged in to Tumblr.
This method takes no parameters and returns an object indicating whether the user is logged in.
GET http://127.0.0.1:8090/tumblr/isLoggedIn
{
"auth": true,
}
Endpoint used for handling passport logins to Tumblr. Redirects to Tumblr for login.
Endpoint used for handling passport logins to YouTube. Allows the response by YouTube to be noted and redirected.
Returns an array of objects of dashboard items from Tumblr. If the user is not logged in, returns a 403 authentication error.
GET http://127.0.0.1:8090/tumblr/dashboard
[
{
"blog_name": "blog name",
"blog": {
...
},
summary: "text content",
...
},
{
"blog_name": "blog name",
"blog": {
...
},
summary: "text content",
...
},
...
]
Check whether authenticated user is logged in to Instagram.
This method takes no parameters and returns an object indicating whether the user is logged in.
GET http://127.0.0.1:8090/instagram/isLoggedIn
{
"auth": true,
}
Endpoint used for handling passport logins to Instagram. Redirects to Instagram for login.
Endpoint used for handling passport logins to Instagram. Allows the response by Instagram to be noted and redirected.
Returns an array of objects of the logged in user's posts to Instagram (endpoints for their feed have been discontinued). If the user is not logged in, returns a 403 authentication error.
GET http://127.0.0.1:8090/instagram/login
[
{
id: "731298",
user: {
...
},
images: {
...
},
...
},
...
]
This endpoint is used to log a user out of their current session, if it exists.
GET http://127.0.0.1:8090/logout
This responds by logging the user out and redirects to http://127.0.0.1:8090.
Returns an array containing jokes on the site. This method takes no parameters.
GET http://127.0.0.1:8090/listJokes
[
{
url: "http://127.0.0.1:8090",
text: "joke here",
author: "Bob"
},
{
url: "http://127.0.0.1:8090",
text: "joke here too",
author: "Joe"
}
]
This method is used to add a joke to the list of joke used by the site.
The user must be logged in with at least one login strategy to add a joke, otherwise, a 403 error is returned.
It takes two parameters, text
(required), containing the joke content, and author
(optional; presumed anonymous otherwise), containing the author of a joke. It returns an object indicating whether the joke has been added.
POST http://127.0.0.1:8090/addPost
text="Post"&author="User"
{
"message": "Success"
}
Returns an array of jokes written by a given author. Takes a single parameter, author
(required).
GET http://127.0.0.1:8090/jokesBy?author=Bob
[
{
url: "http://127.0.0.1:8090",
text: "joke here",
author: "Bob"
}
]
Returns an object indicating if a given person is recognised as a joke author. Takes a single parameter, author
(required).
GET http://127.0.0.1:8090/isJokeAuthor?author=Bob
{
"exists": false,
}
Returns an array containing joke authors. This method takes no parameters.
GET http://127.0.0.1:8090/listJokeAuthors
[
{
name: "user1",
url: "https://www.reddit.com/user/user1"
},
{
name: "user2",
url: "https://www.reddit.com/user/user2"
},
...
]
This method is used to add a joke author to the list of joke authors used by the site.
The user must be logged in with at least one login strategy to add a joke author, otherwise, a 403 error is returned.
It takes two parameters, author
(required), the author's name, and url
(optional), containing a link to their profile. It returns an object indicating whether the author has been added.
POST http://127.0.0.1:8090/addJokeAuthor
author="Lucy"&url="http://www.reddit.com/user/lucy01010101010101017564"
{
"message": "Success",
}
Returns an array containing posts on the site. This method takes no parameters.
GET http://127.0.0.1:8090/listPosts
[
{
url: "http://127.0.0.1:8090",
text: "Post content",
author: "Mary"
},
{
url: "http://127.0.0.1:8090",
text: "Post content too",
author: "Joe"
}
]
This method is used to add a post to the list of posts used by the site.
The user must be logged in with at least one login strategy to add a joke, otherwise, a 403 error is returned.
It takes two parameters, text
(required), containing the post content, and author
(optional; presumed anonymous otherwise), containing the author of a post. It returns an object indicating whether the post has been added.
POST http://127.0.0.1:8090/addPost
text="Post"&author="User"
{
"message": "Joke not provided"
}