import { fileURLToPath as __fileURLToPath } from 'url';
import { dirname as __pathDirname } from 'path';
const __filename = __fileURLToPath(import.meta.url);
const __dirname = __pathDirname(__filename);
function getRailwayConfig() {
  const corsOrigins = process.env.CORS_ORIGINS?.split(",") || [
    "https://claude.ai",
    "https://claude.anthropic.com",
    "http://localhost:3000"
  ];
  let redisUrl = process.env.REDIS_URL || "";
  if (!redisUrl && process.env.REDISHOST) {
    const host = process.env.REDISHOST;
    const port = process.env.REDISPORT || "6379";
    const user = process.env.REDISUSER || "default";
    const password = process.env.REDISPASSWORD || "";
    if (password) {
      redisUrl = `redis://${user}:${password}@${host}:${port}`;
    } else {
      redisUrl = `redis://${host}:${port}`;
    }
  }
  if (!redisUrl && process.env.NODE_ENV !== "production") {
    redisUrl = "redis://localhost:6379";
  }
  return {
    // Server
    port: parseInt(process.env.PORT || "3000"),
    environment: process.env.NODE_ENV || "development",
    // Database - Railway provides this as DATABASE_URL
    databaseUrl: process.env.DATABASE_URL || "postgresql://localhost:5432/stackmemory",
    // Redis
    redisUrl,
    redisHost: process.env.REDISHOST || "localhost",
    redisPort: parseInt(process.env.REDISPORT || "6379"),
    redisUser: process.env.REDISUSER,
    redisPassword: process.env.REDISPASSWORD,
    // Auth
    authMode: process.env.AUTH_MODE || "api_key",
    apiKeySecret: process.env.API_KEY_SECRET || "development-secret",
    jwtSecret: process.env.JWT_SECRET || "development-jwt-secret",
    // Features
    corsOrigins,
    rateLimitEnabled: process.env.RATE_LIMIT_ENABLED === "true",
    rateLimitFree: parseInt(process.env.RATE_LIMIT_FREE || "100"),
    enableWebSocket: process.env.ENABLE_WEBSOCKET !== "false",
    enableAnalytics: process.env.ENABLE_ANALYTICS === "true",
    // Storage mode
    storageMode: process.env.STORAGE_MODE || "hybrid"
  };
}
export {
  getRailwayConfig
};
//# sourceMappingURL=config.js.map
