/**
 * Application Constants
 * Centralized location for all constant values used throughout the application
 */

// ========================================
// API ROUTES
// ========================================

export const API_BASE_ROUTE = "/cfapi"
export const GITHUB_WEBHOOK_PATH = "/cfapi/github"

// Public routes
export const ROUTES = {
  // Root
  ROOT: "/",

  // Public API (no auth)
  HEALTHCHECK: "/healthcheck",
  TEST_SENTRY: "/test-sentry",
  SLACK_EVENTS: "/slack-events",

  // Webhooks
  GITHUB_WEBHOOKS: `${GITHUB_WEBHOOK_PATH}/webhooks`,
  STRIPE_WEBHOOKS: "/cfapi/webhooks/stripe",

  // Optimization
  SUGGEST_PR_CHANGES: "/suggest-pr-changes",
  CREATE_PR: "/create-pr",
  VERIFY_EXISTING_OPTIMIZATIONS: "/verify-existing-optimizations",
  IS_ALREADY_OPTIMIZED: "/is-already-optimized",
  ADD_CODE_HASH: "/add-code-hash",
  MARK_AS_SUCCESS: "/mark-as-success",
  CREATE_STAGING: "/create-staging",
  GET_STAGING_CODE: "/get-staging-code",
  COMMIT_STAGING_CODE: "/commit-staging-code",
  TEST_REPO: "/test-repo",

  // GitHub
  IS_GITHUB_APP_INSTALLED: "/is-github-app-installed",
  SETUP_GITHUB_ACTIONS: "/setup-github-actions",
  CLOSE_PR: "/close-pr",

  // Subscription
  SUBSCRIPTION: "/subscription",
  CREATE_CHECKOUT: "/create-checkout",
  CANCEL_SUBSCRIPTION: "/cancel-subscription",

  // User
  CLI_GET_USER: "/cli-get-user",
  SEND_COMPLETION_EMAIL: "/send-completion-email",
} as const

// Routes that require usage tracking
export const USAGE_TRACKED_ROUTES = [
  ROUTES.SUGGEST_PR_CHANGES,
  ROUTES.CREATE_PR,
  ROUTES.CREATE_STAGING,
]

// ========================================
// SERVER CONFIG
// ========================================

export const DEFAULT_PORT = 3001
export const JSON_BODY_LIMIT = "10mb"

// ========================================
// CRON SCHEDULES
// ========================================

// Run daily at midnight UTC
export const CRON_DAILY_MIDNIGHT = "0 0 * * *"

// ========================================
// RATE LIMITING
// ========================================

export const RATE_LIMIT_WINDOW_MS = 60 * 1000 // 1 minute
export const RATE_LIMIT_MAX_REQUESTS = 100

// ========================================
// EXTERNAL SERVICES
// ========================================

export const POSTHOG_HOST = "https://app.posthog.com"
export const POSTHOG_API_KEY = "phc_aUO790jHd7z1SXwsYCz8dRApxueplZlZWeDSpKc5hol"

// ========================================
// SECURITY
// ========================================

export const SENSITIVE_KEYS = [
  "password",
  "token",
  "secret",
  "key",
  "authorization",
  "access_token",
]

// ========================================
// LOGGING
// ========================================

export const MAX_PENDING_LOGS = 500
export const SERVICE_NAME = "cf-api"

// ========================================
// EMAIL
// ========================================

export const STATUS_EMAIL_RECIPIENTS = {
  to: "sarthak@codeflash.ai",
  cc: ["hesham@codeflash.ai"],
}

export const CRON_EMAIL_SUBJECT_PREFIX = "Cron Job syncOrgsWithMembers"
