export const env = {
  port: Number(process.env.PORT) || 3001,
  databaseUrl: process.env.DATABASE_URL || "",
  jwtSecret: process.env.JWT_SECRET || "dev-secret-change-me",
  isProduction: process.env.NODE_ENV === "production",
  // Whether the refresh cookie is flagged Secure (HTTPS only). Defaults to
  // production, but can be forced off for a plain-HTTP LAN deployment.
  cookieSecure:
    process.env.COOKIE_SECURE !== undefined
      ? process.env.COOKIE_SECURE === "true"
      : process.env.NODE_ENV === "production",
  corsOrigins: (process.env.CORS_ORIGINS || "")
    .split(",")
    .map((s) => s.trim())
    .filter(Boolean),
  // Embedded PGlite data directory (used only when DATABASE_URL is empty)
  pgliteDir: process.env.PGLITE_DIR || "./.pgdata",
};

// Token lifetimes
export const ACCESS_TOKEN_TTL = "15m";
export const REFRESH_TOKEN_TTL_MS = 30 * 24 * 60 * 60 * 1000; // 30 days
export const REFRESH_COOKIE_NAME = "skori_refresh";
