From 566aebd8a4d3b1ba99bad8f8d667516b72c3d1fa Mon Sep 17 00:00:00 2001 From: Liam <67254223+RealFascinated@users.noreply.github.com> Date: Wed, 26 Oct 2022 19:57:43 +0100 Subject: [PATCH] Add env vars type --- src/consts/EnvVars.ts | 17 +++++++++++++++++ src/consts/LeaderboardType.js | 6 ++++-- src/helpers/beatSaverHelpers.ts | 3 ++- src/pages/_app.js | 13 +++++++------ src/pages/_document.js | 3 ++- 5 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 src/consts/EnvVars.ts diff --git a/src/consts/EnvVars.ts b/src/consts/EnvVars.ts new file mode 100644 index 0000000..58a130b --- /dev/null +++ b/src/consts/EnvVars.ts @@ -0,0 +1,17 @@ +type Vars = { + HTTP_PROXY: string; + SITE_NAME: string; + SITE_TITLE: string; + SITE_DESCRIPTION: string; + SITE_COLOR: string; + SITE_URL: string; +}; + +export const VARS: Vars = { + HTTP_PROXY: "HTTP_PROXY", + SITE_NAME: "SITE_NAME", + SITE_TITLE: "SITE_TITLE", + SITE_DESCRIPTION: "SITE_DESCRIPTION", + SITE_COLOR: "SITE_COLOR", + SITE_URL: "SITE_URL", +}; diff --git a/src/consts/LeaderboardType.js b/src/consts/LeaderboardType.js index f71ed4d..a78148c 100644 --- a/src/consts/LeaderboardType.js +++ b/src/consts/LeaderboardType.js @@ -1,10 +1,11 @@ import env from "@beam-australia/react-env"; +import { VARS } from "./EnvVars"; const WebsiteTypes = { ScoreSaber: { ApiUrl: { PlayerData: - env("HTTP_PROXY") + "/https://scoresaber.com/api/player/%s/basic", + env(VARS.HTTP_PROXY) + "/https://scoresaber.com/api/player/%s/basic", MapData: "https://scoresaber.com/api/leaderboard/by-hash/%h/info?difficulty=%d", }, @@ -18,7 +19,8 @@ const WebsiteTypes = { }, BeatLeader: { ApiUrl: { - PlayerData: env("HTTP_PROXY") + "/https://api.beatleader.xyz/player/%s", + PlayerData: + env(VARS.HTTP_PROXY) + "/https://api.beatleader.xyz/player/%s", MapData: "https://api.beatleader.xyz/map/hash/%h", }, async getMapStarCount(mapHash, mapDiff, characteristic) { diff --git a/src/helpers/beatSaverHelpers.ts b/src/helpers/beatSaverHelpers.ts index 73f93aa..0e58a95 100644 --- a/src/helpers/beatSaverHelpers.ts +++ b/src/helpers/beatSaverHelpers.ts @@ -1,9 +1,10 @@ import env from "@beam-australia/react-env"; +import { VARS } from "../consts/EnvVars"; import { BeatSaverMapData } from "../types/BeatSaverMapData"; import { getValue, setValue, valueExists } from "../utils/redisUtils"; const BEATSAVER_MAP_API = - env("HTTP_PROXY") + "/https://api.beatsaver.com/maps/hash/%s"; + env(VARS.HTTP_PROXY) + "/https://api.beatsaver.com/maps/hash/%s"; const KEY = "BS_MAP_DATA_"; diff --git a/src/pages/_app.js b/src/pages/_app.js index 6b7124f..c1f8bc2 100644 --- a/src/pages/_app.js +++ b/src/pages/_app.js @@ -2,6 +2,7 @@ import env from "@beam-australia/react-env"; import { createTheme, NextUIProvider } from "@nextui-org/react"; import { DefaultSeo } from "next-seo"; import { ThemeProvider as NextThemesProvider } from "next-themes"; +import { VARS } from "../consts/EnvVars"; import "../styles/globals.css"; const lightTheme = createTheme({ @@ -22,13 +23,13 @@ function MyApp({ Component, pageProps }) { return ( <> - +