### Next.js Example Setup Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Instructions for setting up the Better Auth Next.js example. Requires cloning the repository, providing environment variables, and running installation and development commands. ```bash pnpm install pnpm run dev ``` -------------------------------- ### Nuxt.js Example Setup Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Instructions for setting up the Better Auth Nuxt.js example. Requires cloning the repository, configuring the .env file, and running installation and development commands. ```bash pnpm install pnpm dev ``` -------------------------------- ### Install Dependencies and Setup Source: https://github.com/devx-op/effectify/blob/master/apps/react-router-example/README.md Commands to install project dependencies, generate Prisma client, run database migrations, initialize better-auth tables, and start the development server. ```bash pnpm install npx prisma generate npx prisma migrate dev sqlite3 dev.db < prisma/better-auth-init.sql pnpm dev ``` -------------------------------- ### Run Example Application Source: https://github.com/devx-op/effectify/blob/master/README.md Starts the example application for TanStack Solid. ```bash pnpm nx dev tanstack-solid-app ``` -------------------------------- ### createAuthEndpoint Example Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt An example demonstrating how to create a GET endpoint for 'Hello World' using `createAuthEndpoint` from Better Auth. ```APIDOC ## GET /my-plugin/hello-world ### Description This endpoint returns a simple "Hello World" message. It's an example of how to define a custom GET endpoint within a Better Auth plugin. ### Method GET ### Endpoint /my-plugin/hello-world ### Parameters ### Request Body ### Request Example ### Response #### Success Response (200) - **message** (string) - A greeting message. #### Response Example ```json { "message": "Hello World" } ``` ``` -------------------------------- ### Basic Auth Server Setup Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/packages/node-auth-app.md Create and start a basic authentication server using default configurations. Ensure the server is running on the specified port. ```typescript import { createAuthApp } from "@effectify/node-auth-app" import { Effect } from "effect" // Create and start the auth server const startAuthServer = Effect.gen(function*() { const app = yield* createAuthApp({ port: 3001, corsOrigin: "http://localhost:3000", database: { provider: "sqlite", url: "file:./auth.db", }, }) console.log("Auth server running on port 3001") return app }) Effect.runPromise(startAuthServer) ``` -------------------------------- ### Basic Fastify Setup with Effect Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/installation.md Example of setting up a basic Fastify server with Effect integration, including registering plugins and defining an Effect-based route. ```typescript // src/index.ts import Fastify from "fastify" import { Effect } from "effect" const fastify = Fastify({ logger: true }) // Register plugins fastify.register(require("@fastify/cors")) fastify.register(require("@fastify/helmet")) // Effect-based route fastify.get("/health", async (request, reply) => { const healthCheck = Effect.succeed({ status: "ok", timestamp: new Date().toISOString(), }) const result = await Effect.runPromise(healthCheck) return result }) const start = async () => { try { await fastify.listen({ port: 3000 }) console.log("Server running on port 3000") } catch (err) { fastify.log.error(err) process.exit(1) } } start() ``` -------------------------------- ### Next.js Project Setup Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/react/installation.md Steps to create a new Next.js project and install Effectify React Query. ```bash npx create-next-app@latest my-app --typescript cd my-app npm install @effectify/react-query @tanstack/react-query effect ``` -------------------------------- ### TanStack Start Server Handler Setup Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Set up the main handler for TanStack Start server routes. This is typically done in a server.ts file. ```typescript import { createStartHandler, defaultStreamHandler } from '@tanstack/react-start/server' import { createRouter } from './router' export default createStartHandler({ createRouter, })(defaultStreamHandler) ``` -------------------------------- ### Install Prisma and Initialize Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/installation.md Install Prisma and its client, then initialize Prisma in your project. ```bash npm install prisma @prisma/client npx prisma init ``` -------------------------------- ### Vite Project Setup Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/react/installation.md Steps to create a new Vite project and install Effectify React Query. ```bash npm create vite@latest my-app -- --template react-ts cd my-app npm install @effectify/react-query @tanstack/react-query effect ``` -------------------------------- ### TanStack Start Server Route Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Set up Better Auth handlers for TanStack Start server routes. This example uses `createServerFileRoute` to define GET and POST methods. ```typescript import { auth } from '~/lib/server/auth' import { createServerFileRoute } from '@tanstack/react-start/server' export const ServerRoute = createServerFileRoute('/api/auth/$').methods({ GET: ({ request }) => { return auth.handler(request) }, POST: ({ request }) => { return auth.handler(request) }, }); ``` -------------------------------- ### Install Dependencies Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/packages/node-auth-app.md Install necessary dependencies for the authentication server. ```bash npm install express cors helmet dotenv better-auth better-sqlite3 ``` -------------------------------- ### Effectify CLI Local Setup Source: https://github.com/devx-op/effectify/blob/master/apps/cli/README.md Provides the necessary bash commands to clone the Effectify repository, install dependencies using Bun, build the CLI, and run it in development mode. ```bash # Clone the monorepo git clone cd effectify # Install dependencies bun install # Build CLI bun nx build cli # Run in development mode bun apps/cli/dist/src/main.js --help ``` -------------------------------- ### Hono Server Setup Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Integrate Better Auth with Hono, a small, fast, and powerful web framework. This example sets up a wildcard route for authentication. ```typescript import { Hono } from "hono"; import { auth } from "./auth"; // path to your auth file import { serve } from "@hono/node-server"; import { cors } from "hono/cors"; const app = new Hono(); app.on(["POST", "GET"], "/api/auth/**", (c) => auth.handler(c.req.raw)); serve(app); ``` -------------------------------- ### Install @effectify/solid-query Source: https://github.com/devx-op/effectify/blob/master/packages/solid/query/README.md Install the package using npm, yarn, pnpm, or bun. ```bash # npm npm install @effectify/solid-query # yarn yarn add @effectify/solid-query # pnpm pnpm add @effectify/solid-query # bun bun add @effectify/solid-query ``` -------------------------------- ### Install UI Components Package Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/react/getting-started.md Install the package for pre-built UI components. ```bash npm install @effectify/react-ui ``` -------------------------------- ### Install Dub SDK with bun Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the Dub SDK using bun. ```bash bun add dub ``` -------------------------------- ### Start Docs Server Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Command to start the documentation development server. ```bash pnpm -F docs dev ``` -------------------------------- ### Install Complete Auth App Package Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/getting-started.md Install the package for a ready-to-deploy authentication service. ```bash npm install @effectify/node-auth-app ``` -------------------------------- ### Start Development Server Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Commands to start the local development server for Effectify. ```bash pnpm dev ``` -------------------------------- ### Install @effectify/solid-ui Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/solid/packages/solid-ui.md Install the @effectify/solid-ui package using npm. Ensure you also install the peer dependencies. ```bash npm install @effectify/solid-ui npm install solid-js tailwindcss @kobalte/core ``` -------------------------------- ### Install @effectify/react-query Source: https://github.com/devx-op/effectify/blob/master/packages/react/query/README.md Install the package using npm, yarn, pnpm, or bun. ```bash # npm npm install @effectify/react-query # yarn yarn add @effectify/react-query # pnpm pnpm add @effectify/react-query # bun bun add @effectify/react-query ``` -------------------------------- ### MongoDB Adapter Setup Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Integrate Better Auth with MongoDB using the mongodbAdapter. Ensure MongoDB is installed and configured. ```typescript import { betterAuth } from "better-auth"; import { MongoClient } from "mongodb"; import { mongodbAdapter } from "better-auth/adapters/mongodb"; const client = new MongoClient("mongodb://localhost:27017/database"); const db = client.db(); export const auth = betterAuth({ database: mongodbAdapter(db), }); ``` -------------------------------- ### Install Plasmo and Better Auth Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Initialize a new Plasmo project with TailwindCSS and install the Better Auth package. Then, start the Plasmo development server. ```bash pnpm create plasmo --with-tailwindcss --with-src pnpm add better-auth pnpm dev ``` -------------------------------- ### Install Bearer Plugin Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Shows how to import and add the bearer plugin to your authentication setup. ```typescript import { betterAuth } from "better-auth"; import { bearer } from "better-auth/plugins"; export const auth = betterAuth({ plugins: [bearer()] }); ``` -------------------------------- ### Install Dependencies Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/solid/packages/solid-effect-atom.md Install the necessary packages for @effectify/solid-effect-atom, @effect-atom/atom, and solid-js. ```bash npm install @effectify/solid-effect-atom @effect-atom/atom effect solid-js ``` -------------------------------- ### Prisma Adapter Setup Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Configure the Prisma adapter for Better Auth. Ensure Prisma is installed and configured, and import the Prisma client from the correct path if a custom output directory is used. ```typescript import { betterAuth } from "better-auth"; import { prismaAdapter } from "better-auth/adapters/prisma"; import { PrismaClient } from "@prisma/client"; const prisma = new PrismaClient(); export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: "sqlite", }), }); ``` -------------------------------- ### Install @effectify/prisma Source: https://github.com/devx-op/effectify/blob/master/packages/prisma/README.md Install the necessary packages for @effectify/prisma, Effect, and Prisma client. ```bash pnpm add -D @effectify/prisma pnpm add effect @prisma/client ``` -------------------------------- ### Fastify Authentication Handler Setup Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Set up a catch-all route in Fastify to process authentication requests. This example demonstrates converting Fastify request details to a Fetch API Request object for Better Auth's handler. ```typescript import Fastify from "fastify"; import { auth } from "./auth"; // Your configured Better Auth instance const fastify = Fastify({ logger: true }); // Register authentication endpoint fastify.route({ method: ["GET", "POST"], url: "/api/auth/*", async handler(request, reply) { try { // Construct request URL const url = new URL(request.url, `http://${request.headers.host}`); // Convert Fastify headers to standard Headers object const headers = new Headers(); Object.entries(request.headers).forEach(([key, value]) => { if (value) headers.append(key, value.toString()); }); // Create Fetch API-compatible request const req = new Request(url.toString(), { method: request.method, headers, body: request.body ? JSON.stringify(request.body) : undefined, }); // Process authentication request const response = await auth.handler(req); // Forward response to client reply.status(response.status); response.headers.forEach((value, key) => reply.header(key, value)); reply.send(response.body ? await response.text() : null); } catch (error) { fastify.log.error("Authentication Error:", error); reply.status(500).send({ error: "Internal authentication error", code: "AUTH_FAILURE" }); } } }); // Initialize server fastify.listen({ port: 4000 }, (err) => { if (err) { fastify.log.error(err); process.exit(1); } console.log("Server running on port 4000"); }); ``` -------------------------------- ### Install @effectify/react-remix Source: https://github.com/devx-op/effectify/blob/master/packages/react/remix/README.md Install the package using npm, yarn, pnpm, or bun. ```bash # npm npm install @effectify/react-remix # yarn yarn add @effectify/react-remix # pnpm pnpm add @effectify/react-remix # bun bun add @effectify/react-remix ``` -------------------------------- ### Elysia Server Setup Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Integrate Better Auth with Elysia, a fast and type-safe web framework. This example defines a handler for authentication routes. ```typescript import { Elysia, Context } from "elysia"; import { auth } from "./auth"; const betterAuthView = (context: Context) => { const BETTER_AUTH_ACCEPT_METHODS = ["POST", "GET"] // validate request method if(BETTER_AUTH_ACCEPT_METHODS.includes(context.request.method)) { return auth.handler(context.request); } else { context.error(405) } } const app = new Elysia().all("/api/auth/*", betterAuthView).listen(3000); console.log( `🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}` ); ``` -------------------------------- ### Basic Server Setup with Effect Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/getting-started.md Sets up an Express server with middleware (helmet, cors, express.json) and integrates Effect for asynchronous operations. Includes a health check endpoint and starts the server using Effect.runPromise. ```typescript import express from "express" import cors from "cors" import helmet from "helmet" import { Effect, Layer } from "effect" import { config } from "./config" import { authRoutes } from "./routes/auth" const app = express() // Middleware app.use(helmet()) app.use(cors()) app.use(express.json()) // Routes app.use("/auth", authRoutes) // Health check app.get("/health", (req, res) => { res.json({ status: "ok", timestamp: new Date().toISOString() }) }) // Start server const startServer = Effect.gen(function*() { const { port } = yield* config return yield* Effect.async((resume) => { const server = app.listen(port, () => { console.log(`Server running on port ${port}`) resume(Effect.succeed(void 0)) }) server.on("error", (error) => { resume(Effect.fail(error)) }) }) }) // Run the server Effect.runPromise(startServer).catch(console.error) ``` -------------------------------- ### Install Dub SDK with pnpm Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the Dub SDK using pnpm. ```bash pnpm add dub ``` -------------------------------- ### Install Winston for Logging Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/installation.md Installs the Winston logging library using npm. ```bash npm install winston ``` -------------------------------- ### Install Chat Components Package Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/react/getting-started.md Install the package for real-time chat functionality. ```bash npm install @effectify/chat-react ``` -------------------------------- ### Install Dub SDK with npm Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the Dub SDK using npm. ```bash npm install dub ``` -------------------------------- ### Install Dependencies Source: https://github.com/devx-op/effectify/blob/master/README.md Installs all project dependencies using pnpm. ```bash pnpm install ``` -------------------------------- ### Install Dependencies Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/react/packages/react-query.md Install the necessary packages for @effectify/react-query integration. ```bash npm install @effectify/react-query @tanstack/react-query effect react ``` -------------------------------- ### Install Dub SDK with yarn Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the Dub SDK using yarn. ```bash yarn add dub ``` -------------------------------- ### Install Better Auth with bun Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the Better Auth package using bun. ```bash bun add better-auth ``` -------------------------------- ### Install @effectify/node-better-auth Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/installation.md Install the core @effectify/node-better-auth package using npm. ```bash npm install @effectify/node-better-auth ``` -------------------------------- ### Install @effectify/react-router Source: https://github.com/devx-op/effectify/blob/master/packages/react/router/README.md Install the package using npm, yarn, pnpm, or bun. ```bash # npm npm install @effectify/react-router # yarn yarn add @effectify/react-router # pnpm pnpm add @effectify/react-router # bun bun add @effectify/react-router ``` -------------------------------- ### Install @effectify/react-query Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/react/installation.md Install the core Effect integration with TanStack Query for React. ```bash npm install @effectify/react-query ``` -------------------------------- ### Install Prisma Client Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the Prisma client for your package manager. This is required for using the Prisma adapter with Better Auth. ```bash npm install @prisma/client ``` ```bash pnpm add @prisma/client ``` ```bash yarn add @prisma/client ``` ```bash bun add @prisma/client ``` -------------------------------- ### Install Stripe SDK (bun) Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the Stripe SDK version 18.0.0 or higher using bun. ```bash bun add stripe@^18.0.0 ``` -------------------------------- ### Local Installation and Build Source: https://github.com/devx-op/effectify/blob/master/apps/cli/README.md Installs dependencies, builds the CLI, and provides the command to run it locally from the monorepo root. ```bash # From monorepo root bun install bun nx build cli # Run CLI bun apps/cli/dist/src/main.js [command] [options] ``` -------------------------------- ### Install Better Auth Stripe Plugin (bun) Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the Better Auth Stripe plugin using bun. ```bash bun add @better-auth/stripe ``` -------------------------------- ### Install Better Auth with npm Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the Better Auth package using npm. ```bash npm install better-auth ``` -------------------------------- ### Install Better Auth with yarn Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the Better Auth package using yarn. ```bash yarn add better-auth ``` -------------------------------- ### Install @effectify/solid-ui Peer Dependencies Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/solid/installation.md Install the peer dependencies for @effectify/solid-ui, including SolidJS, Tailwind CSS, and Kobalte core. ```bash npm install solid-js tailwindcss @kobalte/core ``` -------------------------------- ### Install better-sqlite3 Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/installation.md Install the better-sqlite3 package and its types for SQLite database integration. ```bash npm install better-sqlite3 @types/better-sqlite3 ``` -------------------------------- ### Mount Auth Handler for TanStack Start Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Mount the Better Auth handler to a TanStack API endpoint. This example shows how to handle GET and POST requests. ```typescript import { auth } from '@/lib/auth' // import your auth instance import { createServerFileRoute } from '@tanstack/react-start/server' export const ServerRoute = createServerFileRoute('/api/auth/$').methods({ GET: ({ request }) => { return auth.handler(request) }, POST: ({ request }) => { return auth.handler(request) }, }) ``` -------------------------------- ### Install Stripe SDK (yarn) Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the Stripe SDK version 18.0.0 or higher using yarn. ```bash yarn add stripe@^18.0.0 ``` -------------------------------- ### Install Better Auth with pnpm Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the Better Auth package using pnpm. ```bash pnpm add better-auth ``` -------------------------------- ### Install @effectify/solid-query Peer Dependencies Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/solid/installation.md Install the necessary peer dependencies for @effectify/solid-query, including TanStack Query and Effect. ```bash npm install @tanstack/solid-query effect solid-js ``` -------------------------------- ### Get Session Response Example Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/packages/node-auth-app.md Example JSON response for the GET /api/auth/session endpoint, returning the current user and session details. ```json { "user": {/* user object */}, "session": {/* session object */}, } ``` -------------------------------- ### Create SolidStart Project and Install Dependencies Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/solid/installation.md Initialize a new SolidStart project and install the required Effectify and TanStack Query packages. ```bash npm create solid@latest my-app -- --template solid-start cd my-app npm install @effectify/solid-query @tanstack/solid-query effect ``` -------------------------------- ### Install better-auth plugin with pnpm Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the Dub better-auth plugin using pnpm. ```bash pnpm add @dub/better-auth ``` -------------------------------- ### Get User Profile Response Example Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/packages/node-auth-app.md Example JSON response for the GET /api/auth/user endpoint, detailing the current user's profile information. ```json { "id": "user-id", "email": "user@example.com", "name": "John Doe", "emailVerified": true, "createdAt": "2024-01-01T00:00:00.000Z", "updatedAt": "2024-01-01T00:00:00.000Z", } ``` -------------------------------- ### Start Development Server Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/getting-started.md Execute the development script to launch the server locally. ```bash npm run dev ``` -------------------------------- ### Create React App Setup Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/react/installation.md Steps to set up a new Create React App project with Effectify React Query integration. ```bash npx create-react-app my-app --template typescript cd my-app npm install @effectify/react-query @tanstack/react-query effect ``` -------------------------------- ### Install Stripe SDK (pnpm) Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the Stripe SDK version 18.0.0 or higher using pnpm. ```bash pnpm add stripe@^18.0.0 ``` -------------------------------- ### Install @effectify/chat-solid Peer Dependencies Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/solid/installation.md Install the peer dependencies for @effectify/chat-solid, including Effectify query, domain, and SolidJS. ```bash npm install @effectify/solid-query @effectify/chat-domain solid-js ``` -------------------------------- ### Install @effectify/chat-react Peer Dependencies Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/react/installation.md Install the peer dependencies for `@effectify/chat-react`, including `@effectify/react-query`, `@effectify/chat-domain`, and React. ```bash npm install @effectify/react-query @effectify/chat-domain react ``` -------------------------------- ### Install Better Auth Stripe Plugin (yarn) Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the Better Auth Stripe plugin using yarn. ```bash yarn add @better-auth/stripe ``` -------------------------------- ### Install SolidJS Effectify Packages Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/index.mdx Install the necessary Effectify packages for SolidJS along with TanStack Query and Effect itself. ```bash npm install @effectify/solid-query @tanstack/solid-query effect ``` -------------------------------- ### Initialize Better Auth Project Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Use the `init` command to set up Better Auth in your project. ```bash npx @better-auth/cli@latest init ``` -------------------------------- ### Install PostgreSQL Driver Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install the 'pg' package for PostgreSQL database connections using npm, pnpm, yarn, or bun. ```bash npm install pg ``` ```bash pnpm add pg ``` ```bash yarn add pg ``` ```bash bun add pg ``` -------------------------------- ### Add Scripts to package.json for Express Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/installation.md Example scripts for development, build, and start commands in a Node.js project's package.json. ```json { "scripts": { "dev": "nodemon --exec ts-node src/index.ts", "build": "tsc", "start": "node dist/index.js" } } ``` -------------------------------- ### Environment Variables Configuration Source: https://github.com/devx-op/effectify/blob/master/apps/react-router-example/README.md Example of a .env file for setting up the database connection URL. ```env DATABASE_URL=file:./dev.db ``` -------------------------------- ### Server API Route for Session Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt An example of how to get the user session on a server API route using `auth.api.getSession` by passing request headers. ```typescript import { auth } from "~/lib/auth"; export default defineEventHandler((event) => { const session = await auth.api.getSession({ headers: event.headers }); if(session) { // access the session.session && session.user } }); ``` -------------------------------- ### Create and Configure Fastify Project Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/installation.md Steps to create a new Fastify project and install necessary dependencies. ```bash mkdir my-fastify-backend && cd my-fastify-backend npm init -y npm install fastify @fastify/cors @fastify/helmet npm install -D @types/node typescript ts-node nodemon ``` -------------------------------- ### Initialize Configuration - Custom Registry and Force Source: https://github.com/devx-op/effectify/blob/master/apps/cli/README.md Initializes Effectify configuration, setting a custom registry URL and overwriting any existing configuration file. ```bash effectify init --registry https://my-company-registry.com --force ``` -------------------------------- ### Expo API Route Handler Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Configure Better Auth handlers for Expo API routes. This example exports GET and POST handlers directly from the auth module. ```typescript import { auth } from '@/lib/server/auth'; // path to your auth file const handler = auth.handler; export { handler as GET, handler as POST }; ``` -------------------------------- ### Astro API Route Handler Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Implement Better Auth handlers for Astro API routes. This example shows how to export GET and POST handlers for the auth endpoint. ```typescript import type { APIRoute } from "astro"; import { auth } from "@/auth"; // path to your auth file export const GET: APIRoute = async (ctx) => { return auth.handler(ctx.request); }; export const POST: APIRoute = async (ctx) => { return auth.handler(ctx.request); }; ``` -------------------------------- ### Get Active Organization (Vue) Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt For Vue applications, `authClient.useActiveOrganization()` provides reactive access to the active organization. The setup function returns the reactive data for use in the template. ```typescript ``` -------------------------------- ### Add Verification Component to App Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/solid/installation.md Integrate the TestComponent into your main App component to visually verify the installation. If the text 'Effectify with SolidJS is working!' appears, the setup is successful. ```tsx // src/App.tsx import { TestComponent } from "./components/TestComponent" function App() { return (

My SolidJS + Effectify App

) } export default App ``` -------------------------------- ### Add One-Time Token Server Plugin Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Install and configure the One-Time Token (OTT) plugin in your Better Auth setup to enable the generation and verification of single-use session tokens. ```typescript import { betterAuth } from "better-auth"; import { oneTimeToken } from "better-auth/plugins/one-time-token"; export const auth = betterAuth({ plugins: [ oneTimeToken() ] // ... other auth config }); ``` -------------------------------- ### Get Session in Next.js Server Action Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Retrieve the user's session within a Next.js Server Action. This example demonstrates accessing session data using `auth.api.getSession` with request headers. ```tsx import { auth } from "@/lib/auth" import { headers } from "next/headers" const someAuthenticatedAction = async () => { "use server"; const session = await auth.api.getSession({ headers: await headers() }) }; ``` -------------------------------- ### Basic Auth Handler Setup Source: https://github.com/devx-op/effectify/blob/master/packages/node/better-auth/README.md Set up a basic authentication handler using better-auth with email and password authentication, and a SQLite database. ```typescript // Auth.js import { betterAuth } from "better-auth" import Database from "better-sqlite3" export const handler = betterAuth({ emailAndPassword: { enabled: true, }, database: new Database("../sqlite.db") as any, }) ``` -------------------------------- ### Environment Configuration Example Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/getting-started.md An example .env file for configuring a backend application, including port, Node environment, database connection URL, and JWT/Better Auth secrets. ```env PORT=3000 NODE_ENV=development DATABASE_URL=postgresql://user:password@localhost:5432/myapp JWT_SECRET=your-super-secret-jwt-key BETTER_AUTH_SECRET=your-better-auth-secret BETTER_AUTH_URL=http://localhost:3000 ``` -------------------------------- ### Configure Better Auth Handler in Expo API Route Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Mount the Better Auth handler in an Expo API route to host your Better Auth instance. This example shows how to export the handler for GET and POST requests. ```typescript import { auth } from "@/lib/auth"; // import Better Auth handler const handler = auth.handler; export { handler as GET, handler as POST }; // export handler for both GET and POST requests ``` -------------------------------- ### Sign Up Response Example Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/packages/node-auth-app.md Example JSON response for the POST /api/auth/sign-up endpoint, including user details and session information. ```json { "user": { "id": "user-id", "email": "user@example.com", "name": "John Doe", "emailVerified": false, "createdAt": "2024-01-01T00:00:00.000Z" }, "session": { "id": "session-id", "token": "jwt-token", "expiresAt": "2024-01-08T00:00:00.000Z" } } ``` -------------------------------- ### Create Vite + SolidJS Project and Install Dependencies Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/solid/installation.md Create a new SolidJS project using Vite and install the necessary Effectify and TanStack Query packages. ```bash npm create solid@latest my-app cd my-app npm install @effectify/solid-query @tanstack/solid-query effect ``` -------------------------------- ### Example Sign-In with Email using Auth API Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Demonstrates how to sign in a user with email and password using the Better Auth API. This example is for illustrative purposes and requires cookie handling. ```typescript import { auth } from "@/lib/auth" const signIn = async () => { await auth.api.signInEmail({ body: { email: "user@email.com", password: "password", } }) } ``` -------------------------------- ### Initialize Configuration - Default Source: https://github.com/devx-op/effectify/blob/master/apps/cli/README.md Initializes Effectify configuration in the current project using default settings. ```bash effectify init ``` -------------------------------- ### Sign Up Request Example Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/packages/node-auth-app.md Example JSON payload for the POST /api/auth/sign-up endpoint to register a new user with email, password, and name. ```json { "email": "user@example.com", "password": "securepassword123", "name": "John Doe" } ``` -------------------------------- ### Create and Configure Express Project Source: https://github.com/devx-op/effectify/blob/master/apps/docs/src/content/docs/backend/installation.md Steps to create a new Express.js project, initialize TypeScript, and install development dependencies. ```bash mkdir my-backend && cd my-backend npm init -y npm install express cors helmet dotenv npm install -D @types/express @types/cors @types/node typescript ts-node nodemon ``` -------------------------------- ### Create Project - React App with Features Source: https://github.com/devx-op/effectify/blob/master/apps/cli/README.md Creates a React application named 'my-react-app' with authentication and UI features. ```bash effectify create --template react-app --features auth,ui my-react-app ``` -------------------------------- ### Create Auth Client for Solid Source: https://github.com/devx-op/effectify/blob/master/apps/node-auth-example/LLMs.txt Instantiate the auth client for Solid applications. Configure the base URL for the server. ```typescript import { createAuthClient } from "better-auth/solid" export const authClient = createAuthClient({ /** The base URL of the server (optional if you're using the same domain) */ // [!code highlight] baseURL: "http://localhost:3000" // [!code highlight] }) ```