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