From bfa1337767fd99391e7e1c7e477caf72ce11d96d Mon Sep 17 00:00:00 2001 From: Bereket Engida Date: Fri, 27 Sep 2024 22:07:56 +0300 Subject: [PATCH] docs: fix dep issues --- README.md | 6 +- docs/.env.example | 1 + docs/app/docs/[[...slug]]/page.tsx | 4 +- docs/content/docs/installation.mdx | 6 +- docs/content/docs/introduction.mdx | 7 +- packages/better-auth/src/adapters/index.ts | 1 - packages/better-auth/src/adapters/prisma.ts | 95 --------------------- 7 files changed, 13 insertions(+), 107 deletions(-) create mode 100644 docs/.env.example delete mode 100644 packages/better-auth/src/adapters/index.ts delete mode 100644 packages/better-auth/src/adapters/prisma.ts diff --git a/README.md b/README.md index 5a394e968..bc47abcf5 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,11 @@ ## About the Project -### Why Better Auth? +Better Auth is framework-agnostic authentication (and authorization) library for TypeScript. It provides a comprehensive set of features out of the box and includes a plugin ecosystem that simplifies adding advanced functionalities with minimal code and very short amount time. Whether you need 2FA, multi-tenant support, or other complex features. It lets you focus on building your actual application instead of reinventing the wheel. -Currently, most open-source libraries handle basic authentication, but when you need something more, they often require a lot of additional code. When that happens, instead of just suggesting 3rd party services (which are the right choice in some cases), I think we can do better as a community—hence, Better Auth. +### Why Better Auth + +Currently, the open-source libraries in the ecosystem often require a lot of additional code if you want anything beyond a basic login. Instead of just suggesting 3rd party services when that happens (which can be still be the right choice at times), I think we can do better as a community—hence, Better Auth. ### Goals **** diff --git a/docs/.env.example b/docs/.env.example new file mode 100644 index 000000000..812358268 --- /dev/null +++ b/docs/.env.example @@ -0,0 +1 @@ +NEXT_PUBLIC_URL=http://localhost:3000 \ No newline at end of file diff --git a/docs/app/docs/[[...slug]]/page.tsx b/docs/app/docs/[[...slug]]/page.tsx index 07cbc7db1..1a3c40ff1 100644 --- a/docs/app/docs/[[...slug]]/page.tsx +++ b/docs/app/docs/[[...slug]]/page.tsx @@ -50,7 +50,7 @@ export async function generateStaticParams() { export function generateMetadata({ params }: { params: { slug?: string[] } }) { const page = getPage(params.slug); if (page == null) notFound(); - const baseUrl = process.env.NEXT_APP_PUBLIC_URL; + const baseUrl = process.env.NEXT_APP_PUBLIC_URL || process.env.VERCEL_URL; const url = new URL(`${baseUrl}/api/og`); const { title, description } = page.data; const pageSlug = page.file.path; @@ -64,7 +64,7 @@ export function generateMetadata({ params }: { params: { slug?: string[] } }) { openGraph: { title, description, - type: "Documentation", + type: "website", url: absoluteUrl(`docs/${pageSlug}`), images: [ { diff --git a/docs/content/docs/installation.mdx b/docs/content/docs/installation.mdx index 5ac1d0ea2..dd8566f4b 100644 --- a/docs/content/docs/installation.mdx +++ b/docs/content/docs/installation.mdx @@ -80,10 +80,7 @@ export const auth = betterAuth({ } // [!code highlight] }) ``` - - You can also pass any dialect that is supported by Kysely to the database configration. - **Example with LibsqlDialect:** @@ -99,6 +96,9 @@ export const auth = betterAuth({ }); ``` + + Currently, Better Auth only support databases that are supported by Kysely. [vote this issue if you like to see non sql db support](https://github.com/better-auth/better-auth/issues/5) + diff --git a/docs/content/docs/introduction.mdx b/docs/content/docs/introduction.mdx index 045690e27..4ab193e36 100644 --- a/docs/content/docs/introduction.mdx +++ b/docs/content/docs/introduction.mdx @@ -3,11 +3,11 @@ title: Introduction description: Introduction to Better Auth. --- -Better Auth is framework-agnostic authentication and authorization library for TypeScript. It provides a comprehensive set of features out of the box and includes a plugin ecosystem that simplifies adding advanced functionalities with minimal code. Whether you need 2FA, multi-tenant support, or other complex features. It lets you focus on building your app instead of reinventing the wheel. +Better Auth is framework-agnostic authentication (and authorization) library for TypeScript. It provides a comprehensive set of features out of the box and includes a plugin ecosystem that simplifies adding advanced functionalities with minimal code and very short amount time. Whether you need 2FA, multi-tenant support, or other complex features. It lets you focus on building your actual application instead of reinventing the wheel. ## Why Better Auth? -> Currently, most open-source libraries handle basic authentication, but when you need something more, they often require a lot of additional code. When that happens, instead of just suggesting 3rd party services (which are the right choice in some cases), I think we can do better as a community—hence, Better Auth. +Currently, the open-source libraries in the ecosystem often require a lot of additional code if you want anything beyond a basic login. Instead of just suggesting 3rd party services when that happens (which can be still be the right choice at times), I think we can do better as a community—hence, Better Auth. ## Features @@ -15,5 +15,4 @@ Better auth is aims to be the most comprehensive auth library. It provides a wid -and much more and even more to come... - +and much more and even more to come... \ No newline at end of file diff --git a/packages/better-auth/src/adapters/index.ts b/packages/better-auth/src/adapters/index.ts deleted file mode 100644 index 8e4ed5095..000000000 --- a/packages/better-auth/src/adapters/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./prisma"; diff --git a/packages/better-auth/src/adapters/prisma.ts b/packages/better-auth/src/adapters/prisma.ts deleted file mode 100644 index 31764255d..000000000 --- a/packages/better-auth/src/adapters/prisma.ts +++ /dev/null @@ -1,95 +0,0 @@ -import type { Adapter, Where } from "../types"; - -function whereConvertor(where?: Where[]) { - if (!where) return {}; - if (where.length === 1) { - const w = where[0]; - if (!w) { - return; - } - return { - [w.field]: w.value, - }; - } - const and = where.filter((w) => w.connector === "AND" || !w.connector); - const or = where.filter((w) => w.connector === "OR"); - const andClause = and.map((w) => { - return { - [w.field]: - w.operator === "eq" || !w.operator - ? w.value - : { - [w.operator]: w.value, - }, - }; - }); - const orClause = or.map((w) => { - return { - [w.field]: { - [w.operator || "eq"]: w.value, - }, - }; - }); - - return { - AND: andClause.length ? andClause : undefined, - OR: orClause.length ? orClause : undefined, - }; -} - -export const prismaAdapter = (db: any): Adapter => { - return { - async create(data) { - const { model, data: val, select } = data; - - return await db[model].create({ - data: val, - ...(select?.length - ? { - select: select.reduce((prev, cur) => { - return { - ...prev, - [cur]: true, - }; - }, {}), - } - : {}), - }); - }, - async findOne(data) { - const { model, where, select } = data; - const whereClause = whereConvertor(where); - return await db[model].findFirst({ - where: whereClause, - ...(select?.length - ? { - select: select.reduce((prev, cur) => { - return { - ...prev, - [cur]: true, - }; - }, {}), - } - : {}), - }); - }, - async findMany(data) { - const { model, where } = data; - const whereClause = whereConvertor(where); - return await db[model].findMany({ where: whereClause }); - }, - async update(data) { - const { model, where, update } = data; - const whereClause = whereConvertor(where); - return await db[model].update({ - where: whereClause, - data: update, - }); - }, - async delete(data) { - const { model, where } = data; - const whereClause = whereConvertor(where); - return await db[model].delete({ where: whereClause }); - }, - }; -};