backend/config/index.ts
creations 320e2cc121
All checks were successful
Code quality checks / biome (push) Successful in 7s
Add guild routes, setup tables, validators, and update environment example
Added routes for guild creation, deletion, joining, leaving, and invites
Set up Cassandra tables for guilds, invites, and members
Added validators for guild input
Updated .env.example with required config values
2025-05-03 13:56:57 -04:00

54 lines
1.1 KiB
TypeScript

import { logger } from "@creations.works/logger";
const environment: Environment = {
port: Number.parseInt(process.env.PORT || "", 10),
host: process.env.HOST || "0.0.0.0",
development:
process.env.NODE_ENV === "development" || process.argv.includes("--dev"),
};
const frontend: FrontendConfig = {
origin: process.env.FRONTEND_ORIGIN || "",
};
function verifyRequiredVariables(): void {
const requiredVariables = [
"HOST",
"PORT",
"REDIS_URL",
"REDIS_TTL",
"CASSANDRA_HOST",
"CASSANDRA_PORT",
"CASSANDRA_CONTACT_POINTS",
"CASSANDRA_AUTH_ENABLED",
"CASSANDRA_DATACENTER",
"JWT_SECRET",
"JWT_EXPIRATION",
"JWT_ISSUER",
"FRONTEND_ORIGIN",
];
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 * from "@config/cassandra";
export * from "@config/jwt";
export * from "@config/redis";
export { environment, frontend, verifyRequiredVariables };