This commit is contained in:
commit
9389fd5f8c
15 changed files with 418 additions and 0 deletions
44
config/environment.ts
Normal file
44
config/environment.ts
Normal file
|
@ -0,0 +1,44 @@
|
|||
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.BRANCH || "static-pages",
|
||||
repo: process.env.REPO || "pages",
|
||||
};
|
||||
|
||||
function verifyRequiredVariables(): void {
|
||||
const requiredVariables = [
|
||||
"HOST",
|
||||
"PORT",
|
||||
|
||||
"FORGEJO_URL",
|
||||
"FORGEJO_TOKEN",
|
||||
|
||||
"BRANCH",
|
||||
"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 };
|
Loading…
Add table
Add a link
Reference in a new issue