From 091fea6f3816c8323ab791479da85f5a3a3a9c3b Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 2 May 2025 23:40:34 +0100 Subject: [PATCH] feat: setup better-auth --- apps/web/package.json | 1 + apps/web/src/components/AuthForm.tsx | 9 +- apps/web/src/env.ts | 2 + apps/web/src/pages/api/auth/[...all].ts | 6 + packages/api/package.json | 1 + packages/api/src/trpc.ts | 38 +- packages/auth/eslint.config.js | 9 + packages/auth/package.json | 32 + packages/auth/src/auth.ts | 52 + packages/auth/src/clients.ts | 3 + packages/auth/src/index.ts | 6 + packages/auth/tsconfig.json | 6 + .../db/migrations/0010_wet_true_believers.sql | 87 + .../db/migrations/0011_cultured_red_skull.sql | 8 + .../db/migrations/meta/0010_snapshot.json | 2056 +++++++++++++++++ .../db/migrations/meta/0011_snapshot.json | 2056 +++++++++++++++++ packages/db/migrations/meta/_journal.json | 14 + packages/db/src/repository/user.repo.ts | 1 + packages/db/src/schema/auth.ts | 77 + packages/db/src/schema/index.ts | 2 + packages/db/src/schema/users.ts | 19 +- pnpm-lock.yaml | 239 +- turbo.json | 2 + 23 files changed, 4696 insertions(+), 30 deletions(-) create mode 100644 apps/web/src/pages/api/auth/[...all].ts create mode 100644 packages/auth/eslint.config.js create mode 100644 packages/auth/package.json create mode 100644 packages/auth/src/auth.ts create mode 100644 packages/auth/src/clients.ts create mode 100644 packages/auth/src/index.ts create mode 100644 packages/auth/tsconfig.json create mode 100644 packages/db/migrations/0010_wet_true_believers.sql create mode 100644 packages/db/migrations/0011_cultured_red_skull.sql create mode 100644 packages/db/migrations/meta/0010_snapshot.json create mode 100644 packages/db/migrations/meta/0011_snapshot.json create mode 100644 packages/db/src/schema/auth.ts diff --git a/apps/web/package.json b/apps/web/package.json index cd96c3c7..bca5bec0 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -17,6 +17,7 @@ "@headlessui/react": "^2.2.0", "@hookform/resolvers": "^3.3.4", "@kan/api": "workspace:*", + "@kan/auth": "workspace:*", "@kan/db": "workspace:^", "@kan/shared": "workspace:^", "@kan/supabase": "workspace:^", diff --git a/apps/web/src/components/AuthForm.tsx b/apps/web/src/components/AuthForm.tsx index b1a6dfa2..dcdf03b1 100644 --- a/apps/web/src/components/AuthForm.tsx +++ b/apps/web/src/components/AuthForm.tsx @@ -3,6 +3,8 @@ import { useForm } from "react-hook-form"; import { FaGoogle } from "react-icons/fa"; import { z } from "zod"; +import { authClient } from "@kan/auth"; + import Button from "~/components/Button"; import Input from "~/components/Input"; import { api } from "~/utils/api"; @@ -55,7 +57,12 @@ export function Auth({ setIsMagicLinkSent }: AuthProps) {