add robots txt route, verifiy required env vars func
All checks were successful
Code quality checks / biome (push) Successful in 8s
All checks were successful
Code quality checks / biome (push) Successful in 8s
This commit is contained in:
parent
6b3ead86f7
commit
97d9711372
5 changed files with 67 additions and 13 deletions
|
@ -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 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue