This commit is contained in:
parent
aa24c979ee
commit
a25aff0e24
2 changed files with 51 additions and 10 deletions
|
@ -1,27 +1,69 @@
|
||||||
export const environment: Environment = {
|
import { resolve } from "node:path";
|
||||||
|
import { logger } from "@creations.works/logger";
|
||||||
|
|
||||||
|
const environment: Environment = {
|
||||||
port: Number.parseInt(process.env.PORT || "8080", 10),
|
port: Number.parseInt(process.env.PORT || "8080", 10),
|
||||||
host: process.env.HOST || "0.0.0.0",
|
host: process.env.HOST || "0.0.0.0",
|
||||||
development:
|
development:
|
||||||
process.env.NODE_ENV === "development" || process.argv.includes("--dev"),
|
process.env.NODE_ENV === "development" || process.argv.includes("--dev"),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const redisTtl: number = process.env.REDIS_TTL
|
const redisTtl: number = process.env.REDIS_TTL
|
||||||
? Number.parseInt(process.env.REDIS_TTL, 10)
|
? Number.parseInt(process.env.REDIS_TTL, 10)
|
||||||
: 60 * 60 * 1; // 1 hour
|
: 60 * 60 * 1; // 1 hour
|
||||||
|
|
||||||
export const lanyardConfig: LanyardConfig = {
|
const lanyardConfig: LanyardConfig = {
|
||||||
userId: process.env.LANYARD_USER_ID || "",
|
userId: process.env.LANYARD_USER_ID || "",
|
||||||
instance: process.env.LANYARD_INSTANCE || "https://api.lanyard.rest",
|
instance: process.env.LANYARD_INSTANCE || "",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const reviewDb = {
|
const reviewDb = {
|
||||||
enabled: process.env.REVIEW_DB === "true" || process.env.REVIEW_DB === "1",
|
enabled: process.env.REVIEW_DB === "true" || process.env.REVIEW_DB === "1",
|
||||||
url: "https://manti.vendicated.dev/api/reviewdb",
|
url: "https://manti.vendicated.dev/api/reviewdb",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const badgeApi: string | null = process.env.BADGE_API_URL || null;
|
const badgeApi: string | null = process.env.BADGE_API_URL || null;
|
||||||
export const steamGridDbKey: string | undefined =
|
const steamGridDbKey: string | undefined = process.env.STEAMGRIDDB_API_KEY;
|
||||||
process.env.STEAMGRIDDB_API_KEY;
|
|
||||||
|
|
||||||
export const plausibleScript: string | null =
|
const plausibleScript: string | null =
|
||||||
process.env.PLAUSIBLE_SCRIPT_HTML?.trim() || null;
|
process.env.PLAUSIBLE_SCRIPT_HTML?.trim() || null;
|
||||||
|
|
||||||
|
const robotstxtPath: string | null = process.env.ROBOTS_FILE
|
||||||
|
? resolve(process.env.ROBOTS_FILE)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
function verifyRequiredVariables(): void {
|
||||||
|
const requiredVariables = [
|
||||||
|
"HOST",
|
||||||
|
"PORT",
|
||||||
|
|
||||||
|
"LANYARD_USER_ID",
|
||||||
|
"LANYARD_INSTANCE",
|
||||||
|
];
|
||||||
|
|
||||||
|
let hasError = false;
|
||||||
|
|
||||||
|
for (const key of requiredVariables) {
|
||||||
|
const value = process.env[key];
|
||||||
|
if (value === undefined || value.trim() === "") {
|
||||||
|
logger.error(`Missing or empty environment variable: ${key}`);
|
||||||
|
hasError = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasError) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
environment,
|
||||||
|
lanyardConfig,
|
||||||
|
redisTtl,
|
||||||
|
reviewDb,
|
||||||
|
badgeApi,
|
||||||
|
steamGridDbKey,
|
||||||
|
plausibleScript,
|
||||||
|
robotstxtPath,
|
||||||
|
verifyRequiredVariables,
|
||||||
|
};
|
||||||
|
|
|
@ -4,7 +4,6 @@ import { logger } from "@creations.works/logger";
|
||||||
|
|
||||||
async function main(): Promise<void> {
|
async function main(): Promise<void> {
|
||||||
verifyRequiredVariables();
|
verifyRequiredVariables();
|
||||||
|
|
||||||
serverHandler.initialize();
|
serverHandler.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue