{
  "name": "better-auth",
  "type": "auth",
  "priority": 10,
  "operations": [
    {
      "type": "create-file",
      "source": "shared/lib/auth.ts",
      "destination": "src/lib/auth.ts",
      "condition": { "framework": "express" }
    },
    {
      "type": "create-file",
      "source": "express/types/express.d.ts",
      "destination": "src/types/express.d.ts",
      "condition": { "framework": "express" }
    },
    {
      "type": "create-file",
      "source": "express/config/env.ts",
      "destination": "src/config/env.ts",
      "condition": { "framework": "express" }
    },
    {
      "type": "create-file",
      "source": "express/modules/*",
      "destination": "src/modules/auth/*",
      "condition": { "framework": "express" }
    },
    {
      "type": "create-file",
      "source": "express/mongo-modules/*",
      "destination": "src/modules/auth/*",
      "condition": { "framework": "express", "database": "mongoose" }
    },
    {
      "type": "create-file",
      "source": "express/middlewares/authorize.ts",
      "destination": "src/shared/middlewares/authorize.middleware.ts",
      "condition": { "framework": "express" }
    },
    {
      "type": "create-file",
      "source": "express/templates/*",
      "destination": "src/templates/*",
      "condition": { "framework": "express" }
    },
    {
      "type": "create-file",
      "source": "express/utils/*",
      "destination": "src/shared/utils/*",
      "condition": { "framework": "express" }
    },
    {
      "type": "create-file",
      "source": "shared/utils/email.ts",
      "destination": "src/shared/utils/email.ts",
      "condition": { "framework": "express" }
    },
    {
      "type": "patch-file",
      "destination": "src/app.ts",
      "condition": { "framework": "express" },
      "operations": [
        {
          "type": "add-import",
          "imports": [
            "import { auth } from \"./lib/auth\";",
            "import { toNodeHandler } from \"better-auth/node\";",
            "import { authLimiter } from \"./config/rate-limit\";",
            "import path from \"path\";"
          ]
        },
        {
          "type": "add-code",
          "after": "// API routes",
          "code": ["app.use(\"/api/auth\", authLimiter, (req, res) => {", "  return toNodeHandler(auth)(req, res);", "});"]
        },
        {
          "type": "add-code",
          "after": "app.set(\"query parser\", (str: string) => qs.parse(str));",
          "code": [
            "app.set(\"view engine\", \"ejs\");",
            "app.set(\"views\", path.resolve(process.cwd(), `src/templates`));"
          ]
        }
      ]
    },
    {
      "type": "patch-file",
      "destination": "src/routes/index.ts",
      "condition": { "framework": "express" },
      "operations": [
        {
          "type": "add-import",
          "imports": ["import { authRoutes } from \"../modules/auth/auth.route\";"]
        },
        {
          "type": "add-code",
          "after": "router.use(\"/health\", healthRoutes);",
          "code": ["router.use(\"/auth\", authRoutes);"]
        }
      ]
    },
    {
      "type": "add-dependency",
      "condition": { "framework": "express" },
      "dependencies": {
        "ejs": "^6.0.1",
        "jsonwebtoken": "^9.0.3",
        "better-auth": "^1.6.19",
        "nodemailer": "^9.0.1"
      },
      "devDependencies": {
        "@types/ejs": "^3.1.5",
        "@types/jsonwebtoken": "^9.0.10",
        "@types/nodemailer": "^8.0.1"
      }
    },
    {
      "type": "add-env",
      "condition": { "framework": "express" },
      "envVars": {
        "APP_NAME": "Your App",
        "BETTER_AUTH_URL": "http://localhost:5000",
        "BETTER_AUTH_SECRET": "your_better_auth_secret",
        "BETTER_AUTH_SESSION_TOKEN_EXPIRES_IN": "1d",
        "BETTER_AUTH_SESSION_TOKEN_UPDATE_AGE": "1d",
        "ACCESS_TOKEN_SECRET": "your_access_token_secret",
        "ACCESS_TOKEN_EXPIRES_IN": "1d",
        "REFRESH_TOKEN_SECRET": "your_refresh_token_secret",
        "REFRESH_TOKEN_EXPIRES_IN": "7d",
        "GOOGLE_CLIENT_ID": "your_google_client_id",
        "GOOGLE_CLIENT_SECRET": "your_google_client_secret",
        "GOOGLE_CALLBACK_URL": "http://localhost:5000/api/auth/callback/google",
        "EMAIL_SENDER_SMTP_USER": "your_email@gmail.com",
        "EMAIL_SENDER_SMTP_PASS": "your_email_password",
        "EMAIL_SENDER_SMTP_HOST": "smtp.gmail.com",
        "EMAIL_SENDER_SMTP_PORT": "465",
        "EMAIL_SENDER_SMTP_FROM": "your_email@gmail.com"
      }
    },
    {
      "type": "create-file",
      "source": "nextjs/pages/**",
      "destination": "app/(public)/(auth)/**",
      "condition": { "framework": "nextjs" }
    },
    {
      "type": "create-file",
      "source": "nextjs/layout/layout.tsx",
      "destination": "app/(public)/(root)/layout.tsx",
      "condition": { "framework": "nextjs" }
    },
    {
      "type": "create-file",
      "source": "nextjs/features/**",
      "destination": "features/auth/**",
      "condition": { "framework": "nextjs" }
    },
    {
      "type": "create-file",
      "source": "nextjs/lib/**",
      "destination": "lib/**",
      "condition": { "framework": "nextjs" }
    },
    {
      "type": "create-file",
      "source": "nextjs/proxy.ts",
      "destination": "proxy.ts",
      "condition": { "framework": "nextjs" }
    },
    {
      "type": "create-file",
      "source": "nextjs/api-route.ts",
      "destination": "app/api/auth/callback/[provider]/route.ts",
      "condition": { "framework": "nextjs" }
    },
    {
      "type": "create-file",
      "source": "nextjs/types/**",
      "destination": "types/**",
      "condition": { "framework": "nextjs" }
    },
    {
      "type": "create-file",
      "source": "nextjs/theme/**",
      "destination": "components/**",
      "condition": { "framework": "nextjs", "ui": "shadcn" }
    },
    {
      "type": "create-file",
      "source": "nextjs/dashboard/pages/**",
      "destination": "app/dashboard/**",
      "condition": { "framework": "nextjs", "ui": "shadcn" }
    },
    {
      "type": "patch-file",
      "destination": "app/layout.tsx",
      "condition": { "framework": "nextjs" },
      "operations": [
        {
          "type": "add-import",
          "imports": ["import { ThemeProvider } from \"@/components/providers/theme-provider\";"]
        },
        {
          "type": "add-code",
          "after": "<body className=\"font-sans antialiased\" suppressHydrationWarning>",
          "code": ["<ThemeProvider",
          "  attribute=\"class\"",
          "  defaultTheme=\"system\"",
          "  enableSystem",
          "  disableTransitionOnChange",
          ">"]
        },
        {
          "type": "add-code",
          "before": "</body>",
          "code": ["</ThemeProvider>"]
        }
      ]
    },
    {
      "type": "add-env",
      "condition": { "framework": "nextjs" },
      "envVars": {
        "NEXT_PUBLIC_BETTER_AUTH_URL": "http://localhost:5000",
        "JWT_ACCESS_SECRET": "your_jwt_access_secret"
      }
    },
    {
      "type": "create-file",
      "source": "shared/ui/shadcn/components/**",
      "destination": "{{framework=='nextjs' ? 'components/**' : 'src/components/**'}}",
      "condition": { "framework": ["nextjs", "react"] }
    },
    {
      "type": "create-file",
      "source": "shared/lib/auth-client.ts",
      "destination": "{{framework=='nextjs' ? 'lib/auth/auth-client.ts' : 'src/lib/auth/auth-client.ts'}}",
      "condition": { "framework": ["nextjs", "react"] }
    },
    {
      "type": "create-file",
      "source": "shared/theme/mode-toggle.tsx",
      "destination": "{{framework=='nextjs' ? 'components/mode-toggle.tsx' : 'src/components/mode-toggle.tsx'}}",
      "condition": { "framework": ["nextjs", "react"], "ui": "shadcn" }
    },
    {
      "type": "create-file",
      "source": "shared/ui/shadcn/form-field/*",
      "destination": "{{framework=='nextjs' ? 'components/global/form-field/*' : 'src/components/global/form-field/*'}}",
      "condition": { "framework": ["react", "nextjs"], "ui": "shadcn" }
    },
    {
      "type": "create-file",
      "source": "shared/lib/constant/**",
      "destination": "{{framework=='nextjs' ? 'lib/constant/**' : 'src/lib/constant/**'}}",
      "condition": { "framework": ["react", "nextjs"]}
    },
    {
      "type": "create-file",
      "source": "shared/features/**",
      "destination": "{{framework=='nextjs' ? 'features/auth/**' : 'src/features/auth/**'}}",
      "condition": { "framework": ["react", "nextjs"]}
    },
    {
      "type": "create-file",
      "source": "react/theme/**",
      "destination": "src/**",
      "condition": { "framework": "react", "ui": "shadcn" }
    },
    {
      "type": "create-file",
      "source": "react/components/**",
      "destination": "src/components/**",
      "condition": { "framework": "react" }
    },
    {
      "type": "create-file",
      "source": "react/layout/**",
      "destination": "src/layout/**",
      "condition": { "framework": "react" }
    },
    {
      "type": "create-file",
      "source": "react/lib/**",
      "destination": "src/lib/**",
      "condition": { "framework": "react" }
    },
    {
      "type": "patch-file",
      "destination": "src/main.tsx",
      "condition": { "framework": "react" },
      "operations": [
        {
          "type": "add-import",
          "imports": ["import { ThemeProvider } from \"./components/providers/theme-provider\";"]
        },
        {
          "type": "add-code",
          "after": "<StrictMode>",
          "code": ["<ThemeProvider defaultTheme=\"dark\" storageKey=\"vite-ui-theme\">"]
        },
        {
          "type": "add-code",
          "before": "</StrictMode>,",
          "code": ["</ThemeProvider>"]
        }
      ]
    },
    {
      "type": "create-file",
      "source": "react/router.tsx",
      "destination": "src/router.tsx",
      "condition": { "framework": "react" }
    },
    {
      "type": "create-file",
      "source": "react/dashboard/**",
      "destination": "src/features/dashboard/**",
      "condition": { "framework": "react" }
    },
    {
      "type": "create-file",
      "source": "react/features/**",
      "destination": "src/features/auth/**",
      "condition": { "framework": "react" }
    },
    {
      "type": "create-file",
      "source": "shared/prisma/*",
      "destination": "prisma/*",
      "condition": { "database": "prisma" }
    },
    {
      "type": "add-dependency",
       "condition": { "framework": ["react", "nextjs"] },
      "dependencies": {
        "better-auth": "^1.6.19",
        "zod": "^4.4.3",
        "@hookform/resolvers": "^5.4.0",
        "react-hook-form": "^7.79.0"
      }
    },
    {
      "type": "add-dependency",
      "dependencies": {
        "jsonwebtoken": "^9.0.3",
        "next-themes": "^0.4.6"
      },
      "devDependencies": {
        "@types/jsonwebtoken": "^9.0.10"
      },
      "condition": { "framework": "nextjs" }
    },
    {
      "type": "run-command",
      "command": "{{packageManager=='pnpm' ? 'pnpm dlx shadcn@latest add button card checkbox field input input-group avatar separator sheet textarea label dropdown-menu sidebar skeleton -y' : packageManager=='yarn' ? 'yarn dlx shadcn@latest add button card checkbox field input input-group avatar separator sheet textarea label dropdown-menu sidebar skeleton -y' : packageManager=='bun' ? 'bun dlx shadcn@latest add button card checkbox field input input-group avatar separator sheet textarea label dropdown-menu sidebar skeleton -y' : 'npx shadcn@latest add button card checkbox field input input-group avatar separator sheet textarea label dropdown-menu sidebar skeleton -y'}}",
      "condition": { "framework": ["react", "nextjs"], "ui": "shadcn" }
    }
  ]
}