Replaced config w/ dotenv. Hydrate docker nginx using env. Updated readme
This commit is contained in:
4
.env.example
Normal file
4
.env.example
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
SEASONED_API=
|
||||||
|
ELASTIC=
|
||||||
|
ELASTIC_INDEX=shows,movies
|
||||||
|
SEASONED_DOMAIN=
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,6 @@
|
|||||||
# config file - copy config.json.example
|
# config file - copy config.json.example
|
||||||
src/config.json
|
src/config.json
|
||||||
|
.env
|
||||||
|
|
||||||
# Build directory
|
# Build directory
|
||||||
dist/
|
dist/
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
FROM nginx:1.23.1
|
FROM nginx:1.23.1
|
||||||
|
|
||||||
COPY public /usr/share/nginx/html
|
COPY public /usr/share/nginx/html
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
COPY nginx.conf /etc/nginx/conf.d/default.conf.template
|
||||||
|
COPY docker-entrypoint.sh /docker-entrypoint.d/05-docker-entrypoint.sh
|
||||||
|
|
||||||
|
RUN chmod +x /docker-entrypoint.d/05-docker-entrypoint.sh
|
||||||
|
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|
||||||
|
|||||||
75
README.md
75
README.md
@@ -1,45 +1,72 @@
|
|||||||
# The Movie Database App
|
# Seasoned Request
|
||||||
|
|
||||||
A Vue.js project.
|
Seasoned request is frontend vue application for searching, requesting and viewing account watch activity.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Demo
|
|
||||||
|
|
||||||
[TMDB Vue App](https://tmdb-vue-app.herokuapp.com/)
|
|
||||||
|
|
||||||
## Config setup
|
## Config setup
|
||||||
Set seasonedShows api endpoint and/or elastic.
|
|
||||||
- SeasonedShows [can be found here](https://github.com/kevinmidboe/seasonedshows) and is the matching backend to fetch tmdb search results, tmdb lists, request new content, check plex status and lets owner search and add torrents to download.
|
|
||||||
- Elastic is optional and can be used for a instant search feature for all movies and shows registered in tmdb.
|
|
||||||
|
|
||||||
```json
|
```bash
|
||||||
{
|
# make copy of example environment file
|
||||||
"SEASONED_URL": "http://localhost:31459/api",
|
cp .env.example .env
|
||||||
"ELASTIC_URL": "http://localhost:9200"
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
*Set ELASTIC_URL to undefined or false to disable*
|
|
||||||
|
|
||||||
## Build Setup
|
```bash
|
||||||
|
# .env sane default values
|
||||||
|
SEASONED_API=
|
||||||
|
ELASTIC=
|
||||||
|
ELASTIC_INDEX=shows,movies
|
||||||
|
SEASONED_DOMAIN=
|
||||||
|
```
|
||||||
|
|
||||||
``` bash
|
- Leave SEASONED_API empty to request `/api` from same origin and proxy passed by nginx, set if hosting [seasonedShows backend api](https://github.com/KevinMidboe/seasonedShows) locally.
|
||||||
|
- Elastic is optional and can be used for a instant search feature for all movies and shows registered in tmdb, leave empty to disable.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# .env example values
|
||||||
|
SEASONED_API=http://localhost:31459
|
||||||
|
ELASTIC=http://localhost:9200
|
||||||
|
ELASTIC_INDEX=shows,movies
|
||||||
|
SEASONED_DOMAIN=request.movie
|
||||||
|
```
|
||||||
|
|
||||||
|
## Build Steps
|
||||||
|
|
||||||
|
```bash
|
||||||
# install dependencies
|
# install dependencies
|
||||||
npm install
|
yarn
|
||||||
|
|
||||||
# serve with hot reload at localhost:8080
|
# build vue project using webpack
|
||||||
npm run dev
|
yarn build
|
||||||
|
|
||||||
# build for production with minification
|
# test or host built files using docker, might require sudo:
|
||||||
npm run build
|
docker build -t seasoned .
|
||||||
|
docker run -d -p 5000:5000 --name seasoned-request --env-file .env seasoned
|
||||||
```
|
```
|
||||||
|
|
||||||
For detailed explanation on how things work, consult the [docs for vue-loader](http://vuejs.github.io/vue-loader).
|
## Development Steps
|
||||||
This app uses [history mode](https://router.vuejs.org/en/essentials/history-mode.html)
|
|
||||||
|
```bash
|
||||||
|
# serve project with hot reloading at localhost:8080
|
||||||
|
yarn dev
|
||||||
|
```
|
||||||
|
|
||||||
|
To proxy requests to `/api` either update `SEASONED_API` in `.env` or run set environment variable, e.g.:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# export and run
|
||||||
|
export SEASONED_API=http://localhost:31459
|
||||||
|
yarn dev
|
||||||
|
|
||||||
|
# or run with environment variable inline
|
||||||
|
SEASONED_API=http://localhost:31459 yarn dev
|
||||||
|
```
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
All api functions are documented in `/docs` and [found here](docs/api.md).
|
All api functions are documented in `/docs` and [found here](docs/api.md).
|
||||||
[html version also available](http://htmlpreview.github.io/?https://github.com/KevinMidboe/seasoned/blob/release/v2/docs/api/index.html)
|
[html version also available](http://htmlpreview.github.io/?https://github.com/KevinMidboe/seasoned/blob/release/v2/docs/api/index.html)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
[MIT](https://github.com/dmtrbrl/tmdb-app/blob/master/LICENSE)
|
[MIT](https://github.com/dmtrbrl/tmdb-app/blob/master/LICENSE)
|
||||||
|
|||||||
9
docker-entrypoint.sh
Normal file
9
docker-entrypoint.sh
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
export SEASONED_API=${SEASONED_API:-http://localhost:31459}
|
||||||
|
export SEASONED_DOMAIN=${SEASONED_DOMAIN:-localhost}
|
||||||
|
|
||||||
|
envsubst '$SEASONED_API,$SEASONED_DOMAIN' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
exec "$@"
|
||||||
@@ -2,7 +2,7 @@ server {
|
|||||||
listen 5000 default_server;
|
listen 5000 default_server;
|
||||||
listen [::]:5000 default_server;
|
listen [::]:5000 default_server;
|
||||||
|
|
||||||
# server_name request.movie;
|
server_name $SEASONED_DOMAIN;
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
|
|
||||||
gzip on;
|
gzip on;
|
||||||
@@ -20,7 +20,7 @@ server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
location /api {
|
location /api {
|
||||||
proxy_pass http://request.movie;
|
proxy_pass $SEASONED_API;
|
||||||
}
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chart.js": "3.9.1",
|
"chart.js": "3.9.1",
|
||||||
"connect-history-api-fallback": "2.0.0",
|
"connect-history-api-fallback": "2.0.0",
|
||||||
|
"dotenv": "^16.0.1",
|
||||||
"express": "4.18.1",
|
"express": "4.18.1",
|
||||||
"vue": "3.2.37",
|
"vue": "3.2.37",
|
||||||
"vue-router": "4.1.3",
|
"vue-router": "4.1.3",
|
||||||
|
|||||||
59
src/api.ts
59
src/api.ts
@@ -1,10 +1,7 @@
|
|||||||
import config from "./config";
|
|
||||||
import { IList, IMediaCredits, IPersonCredits } from "./interfaces/IList";
|
import { IList, IMediaCredits, IPersonCredits } from "./interfaces/IList";
|
||||||
|
|
||||||
const { ELASTIC_URL, ELASTIC_INDEX } = config;
|
const { ELASTIC, ELASTIC_INDEX } = process.env;
|
||||||
|
const API_HOSTNAME = window.location.origin;
|
||||||
let { SEASONED_URL } = config;
|
|
||||||
if (!SEASONED_URL) SEASONED_URL = window.location.origin;
|
|
||||||
|
|
||||||
// - - - TMDB - - -
|
// - - - TMDB - - -
|
||||||
|
|
||||||
@@ -21,7 +18,7 @@ const getMovie = (
|
|||||||
releaseDates
|
releaseDates
|
||||||
}: { checkExistance: boolean; credits: boolean; releaseDates?: boolean }
|
}: { checkExistance: boolean; credits: boolean; releaseDates?: boolean }
|
||||||
) => {
|
) => {
|
||||||
const url = new URL("/api/v2/movie", SEASONED_URL);
|
const url = new URL("/api/v2/movie", API_HOSTNAME);
|
||||||
url.pathname = `${url.pathname}/${id.toString()}`;
|
url.pathname = `${url.pathname}/${id.toString()}`;
|
||||||
if (checkExistance) {
|
if (checkExistance) {
|
||||||
url.searchParams.append("check_existance", "true");
|
url.searchParams.append("check_existance", "true");
|
||||||
@@ -55,7 +52,7 @@ const getShow = (
|
|||||||
releaseDates
|
releaseDates
|
||||||
}: { checkExistance: boolean; credits: boolean; releaseDates?: boolean }
|
}: { checkExistance: boolean; credits: boolean; releaseDates?: boolean }
|
||||||
) => {
|
) => {
|
||||||
const url = new URL("/api/v2/show", SEASONED_URL);
|
const url = new URL("/api/v2/show", API_HOSTNAME);
|
||||||
url.pathname = `${url.pathname}/${id.toString()}`;
|
url.pathname = `${url.pathname}/${id.toString()}`;
|
||||||
if (checkExistance) {
|
if (checkExistance) {
|
||||||
url.searchParams.append("check_existance", "true");
|
url.searchParams.append("check_existance", "true");
|
||||||
@@ -82,7 +79,7 @@ const getShow = (
|
|||||||
* @returns {object} Tmdb response
|
* @returns {object} Tmdb response
|
||||||
*/
|
*/
|
||||||
const getPerson = (id, credits = false) => {
|
const getPerson = (id, credits = false) => {
|
||||||
const url = new URL("/api/v2/person", SEASONED_URL);
|
const url = new URL("/api/v2/person", API_HOSTNAME);
|
||||||
url.pathname = `${url.pathname}/${id.toString()}`;
|
url.pathname = `${url.pathname}/${id.toString()}`;
|
||||||
if (credits) {
|
if (credits) {
|
||||||
url.searchParams.append("credits", "true");
|
url.searchParams.append("credits", "true");
|
||||||
@@ -102,7 +99,7 @@ const getPerson = (id, credits = false) => {
|
|||||||
* @returns {object} Tmdb response
|
* @returns {object} Tmdb response
|
||||||
*/
|
*/
|
||||||
const getMovieCredits = (id: number): Promise<IMediaCredits> => {
|
const getMovieCredits = (id: number): Promise<IMediaCredits> => {
|
||||||
const url = new URL("/api/v2/movie", SEASONED_URL);
|
const url = new URL("/api/v2/movie", API_HOSTNAME);
|
||||||
url.pathname = `${url.pathname}/${id.toString()}/credits`;
|
url.pathname = `${url.pathname}/${id.toString()}/credits`;
|
||||||
|
|
||||||
return fetch(url.href)
|
return fetch(url.href)
|
||||||
@@ -119,7 +116,7 @@ const getMovieCredits = (id: number): Promise<IMediaCredits> => {
|
|||||||
* @returns {object} Tmdb response
|
* @returns {object} Tmdb response
|
||||||
*/
|
*/
|
||||||
const getShowCredits = (id: number): Promise<IMediaCredits> => {
|
const getShowCredits = (id: number): Promise<IMediaCredits> => {
|
||||||
const url = new URL("/api/v2/show", SEASONED_URL);
|
const url = new URL("/api/v2/show", API_HOSTNAME);
|
||||||
url.pathname = `${url.pathname}/${id.toString()}/credits`;
|
url.pathname = `${url.pathname}/${id.toString()}/credits`;
|
||||||
|
|
||||||
return fetch(url.href)
|
return fetch(url.href)
|
||||||
@@ -136,7 +133,7 @@ const getShowCredits = (id: number): Promise<IMediaCredits> => {
|
|||||||
* @returns {object} Tmdb response
|
* @returns {object} Tmdb response
|
||||||
*/
|
*/
|
||||||
const getPersonCredits = (id: number): Promise<IPersonCredits> => {
|
const getPersonCredits = (id: number): Promise<IPersonCredits> => {
|
||||||
const url = new URL("/api/v2/person", SEASONED_URL);
|
const url = new URL("/api/v2/person", API_HOSTNAME);
|
||||||
url.pathname = `${url.pathname}/${id.toString()}/credits`;
|
url.pathname = `${url.pathname}/${id.toString()}/credits`;
|
||||||
|
|
||||||
return fetch(url.href)
|
return fetch(url.href)
|
||||||
@@ -154,7 +151,7 @@ const getPersonCredits = (id: number): Promise<IPersonCredits> => {
|
|||||||
* @returns {object} Tmdb list response
|
* @returns {object} Tmdb list response
|
||||||
*/
|
*/
|
||||||
const getTmdbMovieListByName = (name: string, page = 1): Promise<IList> => {
|
const getTmdbMovieListByName = (name: string, page = 1): Promise<IList> => {
|
||||||
const url = new URL(`/api/v2/movie/${name}`, SEASONED_URL);
|
const url = new URL(`/api/v2/movie/${name}`, API_HOSTNAME);
|
||||||
url.searchParams.append("page", page.toString());
|
url.searchParams.append("page", page.toString());
|
||||||
|
|
||||||
return fetch(url.href).then(resp => resp.json());
|
return fetch(url.href).then(resp => resp.json());
|
||||||
@@ -167,7 +164,7 @@ const getTmdbMovieListByName = (name: string, page = 1): Promise<IList> => {
|
|||||||
* @returns {object} Request response
|
* @returns {object} Request response
|
||||||
*/
|
*/
|
||||||
const getRequests = (page = 1) => {
|
const getRequests = (page = 1) => {
|
||||||
const url = new URL("/api/v2/request", SEASONED_URL);
|
const url = new URL("/api/v2/request", API_HOSTNAME);
|
||||||
url.searchParams.append("page", page.toString());
|
url.searchParams.append("page", page.toString());
|
||||||
|
|
||||||
return fetch(url.href).then(resp => resp.json());
|
return fetch(url.href).then(resp => resp.json());
|
||||||
@@ -175,7 +172,7 @@ const getRequests = (page = 1) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getUserRequests = (page = 1) => {
|
const getUserRequests = (page = 1) => {
|
||||||
const url = new URL("/api/v1/user/requests", SEASONED_URL);
|
const url = new URL("/api/v1/user/requests", API_HOSTNAME);
|
||||||
url.searchParams.append("page", page.toString());
|
url.searchParams.append("page", page.toString());
|
||||||
|
|
||||||
return fetch(url.href).then(resp => resp.json());
|
return fetch(url.href).then(resp => resp.json());
|
||||||
@@ -188,7 +185,7 @@ const getUserRequests = (page = 1) => {
|
|||||||
* @returns {object} Tmdb response
|
* @returns {object} Tmdb response
|
||||||
*/
|
*/
|
||||||
const searchTmdb = (query, page = 1, adult = false, mediaType = null) => {
|
const searchTmdb = (query, page = 1, adult = false, mediaType = null) => {
|
||||||
const url = new URL("/api/v2/search", SEASONED_URL);
|
const url = new URL("/api/v2/search", API_HOSTNAME);
|
||||||
if (mediaType != null && ["movie", "show", "person"].includes(mediaType)) {
|
if (mediaType != null && ["movie", "show", "person"].includes(mediaType)) {
|
||||||
url.pathname += `/${mediaType}`;
|
url.pathname += `/${mediaType}`;
|
||||||
}
|
}
|
||||||
@@ -214,7 +211,7 @@ const searchTmdb = (query, page = 1, adult = false, mediaType = null) => {
|
|||||||
* @returns {object} Torrent response
|
* @returns {object} Torrent response
|
||||||
*/
|
*/
|
||||||
const searchTorrents = query => {
|
const searchTorrents = query => {
|
||||||
const url = new URL("/api/v1/pirate/search", SEASONED_URL);
|
const url = new URL("/api/v1/pirate/search", API_HOSTNAME);
|
||||||
url.searchParams.append("query", query);
|
url.searchParams.append("query", query);
|
||||||
|
|
||||||
return fetch(url.href)
|
return fetch(url.href)
|
||||||
@@ -233,7 +230,7 @@ const searchTorrents = query => {
|
|||||||
* @returns {object} Success/Failure response
|
* @returns {object} Success/Failure response
|
||||||
*/
|
*/
|
||||||
const addMagnet = (magnet: string, name: string, tmdbId: number | null) => {
|
const addMagnet = (magnet: string, name: string, tmdbId: number | null) => {
|
||||||
const url = new URL("/api/v1/pirate/add", SEASONED_URL);
|
const url = new URL("/api/v1/pirate/add", API_HOSTNAME);
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -263,7 +260,7 @@ const addMagnet = (magnet: string, name: string, tmdbId: number | null) => {
|
|||||||
* @returns {object} Success/Failure response
|
* @returns {object} Success/Failure response
|
||||||
*/
|
*/
|
||||||
const request = (id, type) => {
|
const request = (id, type) => {
|
||||||
const url = new URL("/api/v2/request", SEASONED_URL);
|
const url = new URL("/api/v2/request", API_HOSTNAME);
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -286,7 +283,7 @@ const request = (id, type) => {
|
|||||||
* @returns {object} Success/Failure response
|
* @returns {object} Success/Failure response
|
||||||
*/
|
*/
|
||||||
const getRequestStatus = (id, type = undefined) => {
|
const getRequestStatus = (id, type = undefined) => {
|
||||||
const url = new URL("/api/v2/request", SEASONED_URL);
|
const url = new URL("/api/v2/request", API_HOSTNAME);
|
||||||
url.pathname = `${url.pathname}/${id.toString()}`;
|
url.pathname = `${url.pathname}/${id.toString()}`;
|
||||||
url.searchParams.append("type", type);
|
url.searchParams.append("type", type);
|
||||||
|
|
||||||
@@ -301,7 +298,7 @@ const getRequestStatus = (id, type = undefined) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const watchLink = (title, year) => {
|
const watchLink = (title, year) => {
|
||||||
const url = new URL("/api/v1/plex/watch-link", SEASONED_URL);
|
const url = new URL("/api/v1/plex/watch-link", API_HOSTNAME);
|
||||||
url.searchParams.append("title", title);
|
url.searchParams.append("title", title);
|
||||||
url.searchParams.append("year", year);
|
url.searchParams.append("year", year);
|
||||||
|
|
||||||
@@ -311,7 +308,7 @@ const watchLink = (title, year) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const movieImages = id => {
|
const movieImages = id => {
|
||||||
const url = new URL(`v2/movie/${id}/images`, SEASONED_URL);
|
const url = new URL(`v2/movie/${id}/images`, API_HOSTNAME);
|
||||||
|
|
||||||
return fetch(url.href).then(resp => resp.json());
|
return fetch(url.href).then(resp => resp.json());
|
||||||
};
|
};
|
||||||
@@ -319,7 +316,7 @@ const movieImages = id => {
|
|||||||
// - - - Seasoned user endpoints - - -
|
// - - - Seasoned user endpoints - - -
|
||||||
|
|
||||||
const register = (username, password) => {
|
const register = (username, password) => {
|
||||||
const url = new URL("/api/v1/user", SEASONED_URL);
|
const url = new URL("/api/v1/user", API_HOSTNAME);
|
||||||
const options = {
|
const options = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
@@ -339,7 +336,7 @@ const register = (username, password) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const login = (username, password, throwError = false) => {
|
const login = (username, password, throwError = false) => {
|
||||||
const url = new URL("/api/v1/user/login", SEASONED_URL);
|
const url = new URL("/api/v1/user/login", API_HOSTNAME);
|
||||||
const options = {
|
const options = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
@@ -356,7 +353,7 @@ const login = (username, password, throwError = false) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const logout = (throwError = false) => {
|
const logout = (throwError = false) => {
|
||||||
const url = new URL("/api/v1/user/logout", SEASONED_URL);
|
const url = new URL("/api/v1/user/logout", API_HOSTNAME);
|
||||||
const options = { method: "POST" };
|
const options = { method: "POST" };
|
||||||
|
|
||||||
return fetch(url.href, options).then(resp => {
|
return fetch(url.href, options).then(resp => {
|
||||||
@@ -369,7 +366,7 @@ const logout = (throwError = false) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getSettings = () => {
|
const getSettings = () => {
|
||||||
const url = new URL("/api/v1/user/settings", SEASONED_URL);
|
const url = new URL("/api/v1/user/settings", API_HOSTNAME);
|
||||||
|
|
||||||
return fetch(url.href)
|
return fetch(url.href)
|
||||||
.then(resp => resp.json())
|
.then(resp => resp.json())
|
||||||
@@ -380,7 +377,7 @@ const getSettings = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updateSettings = settings => {
|
const updateSettings = settings => {
|
||||||
const url = new URL("/api/v1/user/settings", SEASONED_URL);
|
const url = new URL("/api/v1/user/settings", API_HOSTNAME);
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
@@ -399,7 +396,7 @@ const updateSettings = settings => {
|
|||||||
// - - - Authenticate with plex - - -
|
// - - - Authenticate with plex - - -
|
||||||
|
|
||||||
const linkPlexAccount = (username, password) => {
|
const linkPlexAccount = (username, password) => {
|
||||||
const url = new URL("/api/v1/user/link_plex", SEASONED_URL);
|
const url = new URL("/api/v1/user/link_plex", API_HOSTNAME);
|
||||||
const body = { username, password };
|
const body = { username, password };
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
@@ -417,7 +414,7 @@ const linkPlexAccount = (username, password) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const unlinkPlexAccount = () => {
|
const unlinkPlexAccount = () => {
|
||||||
const url = new URL("/api/v1/user/unlink_plex", SEASONED_URL);
|
const url = new URL("/api/v1/user/unlink_plex", API_HOSTNAME);
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -435,7 +432,7 @@ const unlinkPlexAccount = () => {
|
|||||||
// - - - User graphs - - -
|
// - - - User graphs - - -
|
||||||
|
|
||||||
const fetchGraphData = (urlPath, days, chartType) => {
|
const fetchGraphData = (urlPath, days, chartType) => {
|
||||||
const url = new URL(`/api/v1/user/${urlPath}`, SEASONED_URL);
|
const url = new URL(`/api/v1/user/${urlPath}`, API_HOSTNAME);
|
||||||
url.searchParams.append("days", days);
|
url.searchParams.append("days", days);
|
||||||
url.searchParams.append("y_axis", chartType);
|
url.searchParams.append("y_axis", chartType);
|
||||||
|
|
||||||
@@ -452,7 +449,7 @@ const fetchGraphData = (urlPath, days, chartType) => {
|
|||||||
// - - - Random emoji - - -
|
// - - - Random emoji - - -
|
||||||
|
|
||||||
const getEmoji = () => {
|
const getEmoji = () => {
|
||||||
const url = new URL("/api/v1/emoji", SEASONED_URL);
|
const url = new URL("/api/v1/emoji", API_HOSTNAME);
|
||||||
|
|
||||||
return fetch(url.href)
|
return fetch(url.href)
|
||||||
.then(resp => resp.json())
|
.then(resp => resp.json())
|
||||||
@@ -473,7 +470,7 @@ const getEmoji = () => {
|
|||||||
* @returns {object} List of movies and shows matching query
|
* @returns {object} List of movies and shows matching query
|
||||||
*/
|
*/
|
||||||
const elasticSearchMoviesAndShows = (query, count = 22) => {
|
const elasticSearchMoviesAndShows = (query, count = 22) => {
|
||||||
const url = new URL(`${ELASTIC_INDEX}/_search`, ELASTIC_URL);
|
const url = new URL(`${ELASTIC_INDEX}/_search`, ELASTIC);
|
||||||
|
|
||||||
const body = {
|
const body = {
|
||||||
sort: [{ popularity: { order: "desc" } }, "_score"],
|
sort: [{ popularity: { order: "desc" } }, "_score"],
|
||||||
|
|||||||
@@ -86,8 +86,8 @@
|
|||||||
query.value = decodeURIComponent(params.get("query"));
|
query.value = decodeURIComponent(params.get("query"));
|
||||||
}
|
}
|
||||||
|
|
||||||
const elasticUrl = config.ELASTIC_URL;
|
const { ELASTIC } = process.env;
|
||||||
if (elasticUrl === undefined || elasticUrl === "") {
|
if (ELASTIC === undefined || ELASTIC === "") {
|
||||||
disabled.value = true;
|
disabled.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
import type IConfig from "./interfaces/IConfig";
|
|
||||||
|
|
||||||
const config: IConfig = {
|
|
||||||
SEASONED_URL: "",
|
|
||||||
ELASTIC_URL: "https://elastic.kevinmidboe.com/",
|
|
||||||
ELASTIC_INDEX: "shows,movies"
|
|
||||||
};
|
|
||||||
|
|
||||||
export default config;
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
export default interface IConfig {
|
|
||||||
SEASONED_URL: string;
|
|
||||||
ELASTIC_URL: string;
|
|
||||||
ELASTIC_INDEX: string;
|
|
||||||
}
|
|
||||||
@@ -4,6 +4,7 @@ const sass = require("sass");
|
|||||||
const HTMLWebpackPlugin = require("html-webpack-plugin");
|
const HTMLWebpackPlugin = require("html-webpack-plugin");
|
||||||
const { VueLoaderPlugin } = require("vue-loader");
|
const { VueLoaderPlugin } = require("vue-loader");
|
||||||
const TerserPlugin = require("terser-webpack-plugin");
|
const TerserPlugin = require("terser-webpack-plugin");
|
||||||
|
const dotenv = require("dotenv").config({ path: "./.env" });
|
||||||
|
|
||||||
const sourcePath = path.resolve(__dirname, "src");
|
const sourcePath = path.resolve(__dirname, "src");
|
||||||
const indexFile = path.join(sourcePath, "index.html");
|
const indexFile = path.join(sourcePath, "index.html");
|
||||||
@@ -11,6 +12,13 @@ const javascriptEntry = path.join(sourcePath, "main.ts");
|
|||||||
const publicPath = path.resolve(__dirname, "public");
|
const publicPath = path.resolve(__dirname, "public");
|
||||||
const isProd = process.env.NODE_ENV === "production";
|
const isProd = process.env.NODE_ENV === "production";
|
||||||
|
|
||||||
|
// Merge inn all process.env values that match dotenv keys
|
||||||
|
Object.keys(process.env).forEach(key => {
|
||||||
|
if (key in dotenv.parsed) {
|
||||||
|
dotenv.parsed[key] = process.env[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
mode: process.env.NODE_ENV,
|
mode: process.env.NODE_ENV,
|
||||||
context: publicPath,
|
context: publicPath,
|
||||||
@@ -67,6 +75,9 @@ module.exports = {
|
|||||||
template: indexFile,
|
template: indexFile,
|
||||||
filename: "index.html",
|
filename: "index.html",
|
||||||
minify: isProd
|
minify: isProd
|
||||||
|
}),
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
"process.env": JSON.stringify(dotenv.parsed)
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
resolve: {
|
resolve: {
|
||||||
@@ -131,13 +142,13 @@ if (isProd) {
|
|||||||
module.exports.performance.hints = "warning";
|
module.exports.performance.hints = "warning";
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable proxy by running command e.g.:
|
// enable proxy for anything that hits /Api
|
||||||
// proxyhost=https://request.movie yarn dev
|
// View README or update src/config.ts:SEASONED_API_URL
|
||||||
const { proxyhost } = process.env;
|
const { SEASONED_API } = process.env;
|
||||||
if (proxyhost) {
|
if (SEASONED_API) {
|
||||||
module.exports.devServer.proxy = {
|
module.exports.devServer.proxy = {
|
||||||
"/api": {
|
"/api": {
|
||||||
target: proxyhost,
|
target: SEASONED_API,
|
||||||
changeOrigin: true
|
changeOrigin: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4203,6 +4203,11 @@ dotenv@^10.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-10.0.0.tgz#3d4227b8fb95f81096cdd2b66653fb2c7085ba81"
|
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-10.0.0.tgz#3d4227b8fb95f81096cdd2b66653fb2c7085ba81"
|
||||||
integrity sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==
|
integrity sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==
|
||||||
|
|
||||||
|
dotenv@^16.0.1:
|
||||||
|
version "16.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.0.1.tgz#8f8f9d94876c35dac989876a5d3a82a267fdce1d"
|
||||||
|
integrity sha512-1K6hR6wtk2FviQ4kEiSjFiH5rpzEVi8WW0x96aztHVMhEspNpc4DVOUTEHtEva5VThQ8IaBX1Pe4gSzpVVUsKQ==
|
||||||
|
|
||||||
dotgitignore@^2.1.0:
|
dotgitignore@^2.1.0:
|
||||||
version "2.1.0"
|
version "2.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/dotgitignore/-/dotgitignore-2.1.0.tgz#a4b15a4e4ef3cf383598aaf1dfa4a04bcc089b7b"
|
resolved "https://registry.yarnpkg.com/dotgitignore/-/dotgitignore-2.1.0.tgz#a4b15a4e4ef3cf383598aaf1dfa4a04bcc089b7b"
|
||||||
|
|||||||
Reference in New Issue
Block a user