Add env vars type

This commit is contained in:
Liam 2022-10-26 19:57:43 +01:00
parent 8ef4128b45
commit 566aebd8a4
5 changed files with 32 additions and 10 deletions

17
src/consts/EnvVars.ts Normal file

@ -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",
};

@ -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) {

@ -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_";

@ -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 (
<>
<DefaultSeo
titleTemplate={`${env("SITE_NAME")} | %s`}
description={env("SITE_DESCRIPTION}")}
titleTemplate={`${env(VARS.SITE_NAME)} | %s`}
description={env(VARS.SITE_DESCRIPTION)}
openGraph={{
url: env("SITE_URL"),
title: env("SITE_NAME"),
description: env("SITE_DESCRIPTION"),
site_name: env("SITE_NAME"),
url: env(VARS.SITE_URL),
title: env(VARS.SITE_NAME),
description: env(VARS.SITE_DESCRIPTION),
site_name: env(VARS.SITE_NAME),
images: [
{
url: "https://cdn.fascinated.cc/fHknFPctAC.png?raw=true",

@ -2,6 +2,7 @@ import env from "@beam-australia/react-env";
import { CssBaseline, Image } from "@nextui-org/react";
import Document, { Head, Html, Main, NextScript } from "next/document";
import React from "react";
import { VARS } from "../consts/EnvVars";
class MyDocument extends Document {
static async getInitialProps(ctx) {
@ -29,7 +30,7 @@ class MyDocument extends Document {
/>
<link rel="shortcut icon" href="/favicon.ico" />
<meta name="theme-color" content={"#" + env("SITE_COLOR")} />
<meta name="theme-color" content={"#" + env(VARS.SITE_COLOR)} />
<meta
property="og:keywords"
content="BeatSaber,Overlay,OBS,Twitch,YouTube,BeatSaber Overlay,Github,"