All checks were successful
Code quality checks / biome (push) Successful in 13s
44 lines
990 B
TypeScript
44 lines
990 B
TypeScript
import { logger } from "@creations.works/logger";
|
|
|
|
const environment: Environment = {
|
|
port: Number.parseInt(process.env.PORT || "8080", 10),
|
|
host: process.env.HOST || "0.0.0.0",
|
|
development:
|
|
process.env.NODE_ENV === "development" || process.argv.includes("--dev"),
|
|
};
|
|
|
|
const forgejo = {
|
|
url: process.env.FORGEJO_URL || "",
|
|
token: process.env.FORGEJO_TOKEN || "",
|
|
branch: process.env.FORGEJO_BRANCH || "static-pages",
|
|
repo: process.env.FORGEJO_REPO || "pages",
|
|
};
|
|
|
|
function verifyRequiredVariables(): void {
|
|
const requiredVariables = [
|
|
"HOST",
|
|
"PORT",
|
|
|
|
"FORGEJO_URL",
|
|
"FORGEJO_TOKEN",
|
|
|
|
"FORGEJO_BRANCH",
|
|
"FORGEJO_REPO",
|
|
];
|
|
|
|
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, forgejo, verifyRequiredVariables };
|