* Migrate authentication from Clerk to BetterAuth (#322) Replaces @clerk/react-router with self-hosted better-auth to eliminate the external Clerk dependency and keep all user/session data in our own PostgreSQL database. **What changed** - New: auth.server.ts (BetterAuth config w/ Drizzle adapter, bcrypt, Resend), auth-client.ts, api.auth.$.ts handler - New: /login and /register pages with email+password and Google/Discord OAuth; open-redirect guard on redirectTo param - New: UserMenu component replacing Clerk's UserButton - Schema: sessions, accounts, verifications tables; emailVerified column; clerkId made nullable - Migrations 0081 (BetterAuth tables) and 0082 (accounts extra columns for v1.6.9) - All ~30 route files: getAuth → auth.api.getSession, isUserAdminByClerkId → isUserAdmin - root.tsx: isAdmin read directly from session.user.isAdmin (no extra DB query) - useDraftAuthRecovery: removed Clerk JWT refresh logic; replaced with cookie-session check - models/user.ts: removed findUserByClerkId, findOrCreateUser, updateUserByClerkId (webhook pattern) - Deleted: app/routes/api/webhooks/clerk.ts; uninstalled @clerk/react-router, @clerk/themes, svix - scripts/migrate.mjs: extended with idempotent Clerk → BetterAuth data migration (FK conversion, email_verified, OAuth accounts) - scripts/migrate-clerk-passwords.mjs: one-time script to import bcrypt hashes from Clerk CSV export - BETTERAUTH_MIGRATION.md: dev and production runbooks - All test mocks updated: vi.mock('~/lib/auth.server') instead of @clerk/react-router/server - Test fixtures: added emailVerified field **Follow-up (post-stable)** - Rename actor_clerk_id column → actor_user_id in commissioner_audit_log - Drop clerk_id column from users once migration confirmed Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Add .npmrc with legacy-peer-deps for better-auth/drizzle peer dep conflict better-auth@1.6.9 declares peerOptional deps on drizzle-orm ^0.45.2 and drizzle-kit >=0.31.4, but we run drizzle-orm ~0.36.3 / drizzle-kit ~0.28.1. The adapter works correctly at runtime with our versions — the peer dep is only for stricter type checking. This unblocks npm ci in CI without a risky drizzle major-version upgrade. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
122 lines
4.3 KiB
JSON
122 lines
4.3 KiB
JSON
{
|
|
"name": "brackt.com",
|
|
"private": true,
|
|
"type": "module",
|
|
"scripts": {
|
|
"build": "npm run build:remix && npm run build:server",
|
|
"build:remix": "react-router build",
|
|
"build:server": "node scripts/build-server.mjs",
|
|
"db:generate": "dotenv -- drizzle-kit generate",
|
|
"db:migrate": "dotenv -- drizzle-kit migrate",
|
|
"db:sync-prod": "bash scripts/sync-prod-db.sh",
|
|
"dev": "NODE_OPTIONS='--import ./instrument.server.mjs' dotenv -- tsx watch server.ts",
|
|
"start": "NODE_ENV=production NODE_OPTIONS='--import ./instrument.server.mjs' node dist/server.js",
|
|
"start:production": "NODE_ENV=production NODE_OPTIONS='--import ./instrument.server.mjs' node dist/server.js",
|
|
"test": "vitest",
|
|
"test:ui": "vitest --ui",
|
|
"test:coverage": "vitest --coverage",
|
|
"test:run": "vitest run --project=unit",
|
|
"test:storybook": "vitest run --project=storybook",
|
|
"test:e2e": "cypress open",
|
|
"test:e2e:headless": "cypress run",
|
|
"test:all": "npm run test:run && npm run test:e2e:headless",
|
|
"typecheck": "react-router typegen && tsc -b && tsc -p tsconfig.server.json --noEmit",
|
|
"lint": "oxlint app/ server/ database/",
|
|
"lint:path": "oxlint",
|
|
"lint:fix": "oxlint app/ server/ database/ --fix",
|
|
"storybook": "storybook dev -p 6006",
|
|
"build-storybook": "storybook build"
|
|
},
|
|
"dependencies": {
|
|
"@dnd-kit/core": "^6.3.1",
|
|
"@dnd-kit/sortable": "^10.0.0",
|
|
"@dnd-kit/utilities": "^3.2.2",
|
|
"@marsidev/react-turnstile": "^1.4.2",
|
|
"@radix-ui/react-accordion": "^1.2.12",
|
|
"@radix-ui/react-alert-dialog": "^1.1.15",
|
|
"@radix-ui/react-checkbox": "^1.3.3",
|
|
"@radix-ui/react-collapsible": "^1.1.12",
|
|
"@radix-ui/react-context-menu": "^2.2.16",
|
|
"@radix-ui/react-dialog": "^1.1.15",
|
|
"@radix-ui/react-label": "^2.1.7",
|
|
"@radix-ui/react-navigation-menu": "^1.2.14",
|
|
"@radix-ui/react-popover": "^1.1.15",
|
|
"@radix-ui/react-radio-group": "^1.3.8",
|
|
"@radix-ui/react-select": "^2.2.6",
|
|
"@radix-ui/react-slot": "^1.2.3",
|
|
"@radix-ui/react-switch": "^1.2.6",
|
|
"@radix-ui/react-tabs": "^1.1.13",
|
|
"@react-router/express": "^7.7.1",
|
|
"@react-router/node": "^7.7.1",
|
|
"@sentry/react-router": "^10.43.0",
|
|
"@tanstack/react-virtual": "^3.13.24",
|
|
"@types/nprogress": "^0.2.3",
|
|
"bcrypt": "^6.0.0",
|
|
"better-auth": "^1.6.9",
|
|
"class-variance-authority": "^0.7.1",
|
|
"clsx": "^2.1.1",
|
|
"compression": "^1.8.0",
|
|
"date-fns": "^4.1.0",
|
|
"drizzle-orm": "~0.36.3",
|
|
"express": "^5.1.0",
|
|
"isbot": "^5.1.27",
|
|
"lucide-react": "^1.8.0",
|
|
"morgan": "^1.10.0",
|
|
"next-themes": "^0.4.6",
|
|
"nprogress": "^0.2.0",
|
|
"postgres": "^3.4.5",
|
|
"react": "^19.1.0",
|
|
"react-day-picker": "^9.11.1",
|
|
"react-dom": "^19.1.0",
|
|
"react-router": "^7.7.1",
|
|
"recharts": "^3.4.1",
|
|
"resend": "^6.9.4",
|
|
"socket.io": "^4.8.1",
|
|
"socket.io-client": "^4.8.1",
|
|
"sonner": "^2.0.7",
|
|
"tailwind-merge": "^3.3.1",
|
|
"zod": "^4.3.6"
|
|
},
|
|
"devDependencies": {
|
|
"@react-router/dev": "^7.7.1",
|
|
"@storybook/addon-a11y": "^10.3.3",
|
|
"@storybook/addon-docs": "^10.3.3",
|
|
"@storybook/addon-vitest": "^10.3.3",
|
|
"@storybook/react-vite": "^10.3.3",
|
|
"@tailwindcss/vite": "^4.1.4",
|
|
"@testing-library/cypress": "^10.1.0",
|
|
"@testing-library/jest-dom": "^6.9.1",
|
|
"@testing-library/react": "^16.3.0",
|
|
"@testing-library/user-event": "^14.6.1",
|
|
"@types/bcrypt": "^6.0.0",
|
|
"@types/compression": "^1.8.1",
|
|
"@types/express": "^5.0.3",
|
|
"@types/express-serve-static-core": "^5.0.6",
|
|
"@types/morgan": "^1.9.10",
|
|
"@types/node": "^20",
|
|
"@types/pg": "^8.11.14",
|
|
"@types/react": "^19.1.2",
|
|
"@types/react-dom": "^19.1.2",
|
|
"@vitejs/plugin-react": "^5.0.4",
|
|
"@vitest/browser": "^3.2.4",
|
|
"@vitest/coverage-v8": "^3.2.4",
|
|
"@vitest/ui": "^3.2.4",
|
|
"cypress": "^14.5.4",
|
|
"dotenv-cli": "^8.0.0",
|
|
"drizzle-kit": "~0.28.1",
|
|
"esbuild": "^0.25.11",
|
|
"jsdom": "^27.0.1",
|
|
"oxlint": "^1.56.0",
|
|
"playwright": "^1.58.2",
|
|
"shadcn": "^4.0.8",
|
|
"storybook": "^10.3.3",
|
|
"storybook-addon-remix-react-router": "^6.1.0",
|
|
"tailwindcss": "^4.1.4",
|
|
"tsx": "^4.20.6",
|
|
"tw-animate-css": "^1.4.0",
|
|
"typescript": "^5.8.3",
|
|
"vite": "^6.3.3",
|
|
"vite-tsconfig-paths": "^5.1.4",
|
|
"vitest": "^3.2.4"
|
|
}
|
|
}
|