Endpoint for most watched and tests.

This commit is contained in:
mike.rode
2019-02-13 00:57:04 -06:00
parent 066d05b1be
commit ca92855171
7 changed files with 582 additions and 5 deletions
+1
View File
@@ -4,5 +4,6 @@ import plexService from '../../../services/plexApi';
const router = Router();
router.get('/users', plexService.getUsers);
router.get('/most-watched', plexService.getMostWatched);
export default router;
+7
View File
@@ -6,6 +6,13 @@ const getUsers = async (req, res) => {
res.json(users);
};
const getMostWatched = async (req, res) => {
const plexApi = plexApiClient();
const mostWatched = await plexApi.getMostWatched(2);
res.json(mostWatched);
};
export default {
getUsers,
getMostWatched,
};
+1 -2
View File
@@ -90,9 +90,8 @@ PlexApiClient.prototype.getUsers = async function() {
PlexApiClient.prototype.getMostWatched = async function(type, limit = 10) {
const urlParams = this.mostWatchedUrlParams(type, limit);
const mostWatchedUrl = this.buildUrl(urlParams);
console.log(mostWatchedUrl);
const response = await this.request(mostWatchedUrl);
return response;
return response.MediaContainer.Metadata;
};
const plexApiClient = (options = []) => {