-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from justinhartman/develop
Merge watchlist and style changes to main
- Loading branch information
Showing
28 changed files
with
654 additions
and
427 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
const axios = require("axios"); | ||
const asyncHandler = require('express-async-handler'); | ||
|
||
const { | ||
fetchOmdbData, | ||
fetchAndUpdatePosters | ||
} = require('../helpers/appHelper'); | ||
|
||
/** | ||
* @module appController | ||
* @description This module contains the standard application controller functions. | ||
*/ | ||
const appController = { | ||
/** | ||
* @function getHome | ||
* @memberof appController | ||
* @param {Request} req - Express request object. | ||
* @param {Response} res - Express response object. | ||
* @description This handles the rendering the home page with new movies and TV shows. | ||
* It sets the canonical URL and renders the 'index' template with the specified parameters. | ||
* @return {Promise<void>} | ||
*/ | ||
getHome: asyncHandler(async (req, res) => { | ||
const query = req.query.q || ''; | ||
const type = req.query.type || 'ovie'; | ||
const canonical = res.locals.APP_URL; | ||
let newMovies = []; | ||
let newSeries = []; | ||
|
||
/** | ||
* Fetch new movies from VidSrc. | ||
* You can switch to new movies instead of the default 'added' with 'https://vidsrc.to/vapi/movie/new' | ||
* @type {axios.AxiosResponse<any>} | ||
* @docs https://vidsrc.to/#api | ||
*/ | ||
const axiosMovieResponse = await axios.get('https://vidsrc.to/vapi/movie/add'); | ||
newMovies = axiosMovieResponse.data.result.items || []; | ||
await fetchAndUpdatePosters(newMovies); | ||
|
||
/** | ||
* Fetch new TV shows from VidSrc. | ||
* You can switch to new movies instead of the default 'added' with 'https://vidsrc.to/vapi/tv/new' | ||
* @type {axios.AxiosResponse<any>} | ||
* @docs https://vidsrc.to/#api | ||
*/ | ||
const axiosSeriesResponse = await axios.get('https://vidsrc.to/vapi/tv/add'); | ||
newSeries = axiosSeriesResponse.data.result.items || []; | ||
await fetchAndUpdatePosters(newSeries); | ||
|
||
res.render('index', { newMovies, newSeries, query, type, canonical, card: res.locals.CARD_TYPE, user: req.user }); | ||
}), | ||
|
||
/** | ||
* @function getView | ||
* @memberof appController | ||
* @param {Request} req - Express request object. | ||
* @param {Response} res - Express response object. | ||
* @description This function handles the rendering of a movie or TV video player page. | ||
* It sets the canonical URL and renders the 'view' template and returns the iFrame VidSrc URL | ||
* along with parsed OMDB data for the template. | ||
* @returns {Promise<void>} | ||
*/ | ||
getView: asyncHandler(async (req, res) => { | ||
const query = req.params.q || ''; | ||
const id = req.params.id; | ||
let type = req.params.type; | ||
let t = 'movie'; | ||
if (type === 'series') t = 'tv' | ||
const iframeSrc = `https://vidsrc.to/embed/${t}/${id}`; | ||
const canonical = `${res.locals.APP_URL}/view/${id}/${type}`; | ||
const data = await fetchOmdbData(id, false); | ||
res.render('view', { data, iframeSrc, query, id, type, canonical, user: req.user }); | ||
}), | ||
|
||
/** | ||
* @function getSearch | ||
* @memberof appController | ||
* @param {Request} req - Express request object. | ||
* @param {Response} res - Express response object. | ||
* @description This function handles the rendering of the search results page. | ||
* It sets the canonical URL and renders the 'search' template with the specified parameters. | ||
* @return {Promise<void>} | ||
*/ | ||
getSearch: asyncHandler(async (req, res) => { | ||
const query = req.query.q.trim(); | ||
const type = req.query.type || 'movie'; | ||
const omdbSearch = await fetchOmdbData(query, true, type); | ||
const results = omdbSearch.Search || []; | ||
const canonical = `${res.locals.APP_URL}/search/?q=${query}&type=${type}`; | ||
if (!query) res.redirect('/'); | ||
res.render('search', { query, results, type, canonical, card: res.locals.CARD_TYPE, user: req.user }); | ||
}) | ||
}; | ||
|
||
module.exports = appController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<img align="right" src="https://github.com/justinhartman/imdb-app/raw/main/public/images/favicons/apple-touch-icon.png" /> | ||
|
||
# IMDb Movie & TV Search Engine WebApp | ||
|
||
_This file contains the changelog revisions for the IMDb Movie & TV Search Engine WebApp._ | ||
|
||
### Bug Fixes | ||
|
||
- [42b0cf61](https://github.com/justinhartman/imdb-app/commit/42b0cf61982264da7a7fad7c37c74a166fd98c5d): Fix error where DB connects to test DB incorrectly | ||
|
||
### Core Updates | ||
|
||
- [e1054ca2](https://github.com/justinhartman/imdb-app/commit/e1054ca297137ed28d1c2ff12a38d124d3e5a6e9): Set mongoose to connect on IPV4 by default | ||
|
||
### Yarn Package Updates | ||
|
||
- [9f1c5d7f](https://github.com/justinhartman/imdb-app/commit/9f1c5d7fb98700b73b3d187cbd7a4bf4881e6a7b): Remove duplicate script command | ||
|
||
### Pull Requests Merged | ||
|
||
- [9dd770cf](https://github.com/justinhartman/imdb-app/commit/9dd770cf93655715d720a535963258b969cf1db4): Merge pull request #10 from justinhartman/develop | ||
- [a085865f](https://github.com/justinhartman/imdb-app/commit/a085865f793b4ad2462f0d10940f62cc0c85452d): Merge pull request #9 from justinhartman/develop | ||
- [c4bacfaf](https://github.com/justinhartman/imdb-app/commit/c4bacfaff39cb1bb3fd9d10af0d7d6c61c3b59ea): Merge pull request #8 from justinhartman/main | ||
|
Oops, something went wrong.