mirror of
https://github.com/KevinMidboe/seasoned.git
synced 2026-03-10 11:29:07 +00:00
vite environment variables, also typed
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
SEASONED_API=
|
SEASONED_API=http://localhost:31459
|
||||||
ELASTIC=
|
ELASTIC_URL=http://elastic.local:9200/tmdb-movies-shows
|
||||||
ELASTIC_INDEX=shows,movies
|
ELASTIC_API_KEY=
|
||||||
SEASONED_DOMAIN=
|
|
||||||
|
|||||||
11
src/api.ts
11
src/api.ts
@@ -1,8 +1,8 @@
|
|||||||
import { IList, IMediaCredits, IPersonCredits } from "./interfaces/IList";
|
import { IList, IMediaCredits, IPersonCredits } from "./interfaces/IList";
|
||||||
|
|
||||||
const ELASTIC = import.meta.env.VITE_ELASTIC;
|
|
||||||
const ELASTIC_INDEX = import.meta.env.VITE_ELASTIC_INDEX;
|
|
||||||
const API_HOSTNAME = import.meta.env.VITE_SEASONED_API;
|
const API_HOSTNAME = import.meta.env.VITE_SEASONED_API;
|
||||||
|
const ELASTIC_URL = import.meta.env.VITE_ELASTIC_URL;
|
||||||
|
const ELASTIC_API_KEY = import.meta.env.VITE_ELASTIC_API_KEY;
|
||||||
|
|
||||||
// - - - TMDB - - -
|
// - - - TMDB - - -
|
||||||
|
|
||||||
@@ -471,7 +471,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);
|
const url = new URL(`${ELASTIC_URL}/_search`);
|
||||||
|
|
||||||
const body = {
|
const body = {
|
||||||
sort: [{ popularity: { order: "desc" } }, "_score"],
|
sort: [{ popularity: { order: "desc" } }, "_score"],
|
||||||
@@ -496,7 +496,10 @@ const elasticSearchMoviesAndShows = (query, count = 22) => {
|
|||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Authorization: `ApiKey ${ELASTIC_API_KEY}`
|
||||||
|
},
|
||||||
body: JSON.stringify(body)
|
body: JSON.stringify(body)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -85,8 +85,9 @@
|
|||||||
query.value = decodeURIComponent(params.get("query"));
|
query.value = decodeURIComponent(params.get("query"));
|
||||||
}
|
}
|
||||||
|
|
||||||
const { ELASTIC } = process.env;
|
const ELASTIC_URL = import.meta.env.VITE_ELASTIC_URL;
|
||||||
if (ELASTIC === undefined || ELASTIC === "") {
|
const ELASTIC_API_KEY = import.meta.env.VITE_ELASTIC_API_KEY;
|
||||||
|
if (!ELASTIC_URL || !ELASTIC_API_KEY) {
|
||||||
disabled.value = true;
|
disabled.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
5
src/vite-env.d.ts
vendored
5
src/vite-env.d.ts
vendored
@@ -1,8 +1,7 @@
|
|||||||
interface ImportMetaEnv {
|
interface ImportMetaEnv {
|
||||||
readonly VITE_SEASONED_API: string;
|
readonly VITE_SEASONED_API: string;
|
||||||
readonly VITE_ELASTIC: string;
|
readonly VITE_ELASTIC_URL: string;
|
||||||
readonly VITE_ELASTIC_INDEX: string;
|
readonly VITE_ELASTIC_API_KEY: string;
|
||||||
readonly VITE_SEASONED_DOMAIN: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ImportMeta {
|
interface ImportMeta {
|
||||||
|
|||||||
Reference in New Issue
Block a user