add robots txt route, verifiy required env vars func
All checks were successful
Code quality checks / biome (push) Successful in 8s

This commit is contained in:
creations 2025-05-12 18:13:29 -04:00
parent 6b3ead86f7
commit 97d9711372
Signed by: creations
GPG key ID: 8F553AA4320FC711
5 changed files with 67 additions and 13 deletions

View file

@ -1,6 +1,33 @@
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),
host: process.env.HOST || "0.0.0.0",
development:
process.env.NODE_ENV === "development" || process.argv.includes("--dev"),
};
const robotstxtPath: string | null = process.env.ROBOTS_FILE
? resolve(process.env.ROBOTS_FILE)
: null;
function verifyRequiredVariables(): void {
const requiredVariables = ["HOST", "PORT"];
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, robotstxtPath, verifyRequiredVariables };