UNPKG

@reliverse/rse

Version:

@reliverse/rse is your all-in-one companion for bootstrapping and improving any kind of projects (especially web apps built with frameworks like Next.js) — whether you're kicking off something new or upgrading an existing app. It is also a little AI-power

1,695 lines 124 kB
export const DLER_TPL_AUTH = { name: "auth", description: "Template generated from 58 files", updatedAt: "2025-06-17T20:33:59.599Z", config: { files: { "auth/native/native-base/lib/auth-client.ts.hbs": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "0200f4eedc" }, content: `import { createAuthClient } from "better-auth/react"; import { expoClient } from "@better-auth/expo/client"; import * as SecureStore from "expo-secure-store"; export const authClient = createAuthClient({ baseURL: process.env.EXPO_PUBLIC_SERVER_URL, plugins: [ expoClient({ storagePrefix: "my-better-t-app", storage: SecureStore, }), ], }); `, type: "text" }, "auth/native/nativewind/app/(drawer)/index.tsx.hbs": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "c97ce0cd75" }, content: `import { authClient } from "@/lib/auth-client"; import { useQuery } from "@tanstack/react-query"; import { ScrollView, Text, TouchableOpacity, View } from "react-native"; import { Container } from "@/components/container"; import { SignIn } from "@/components/sign-in"; import { SignUp } from "@/components/sign-up"; {{#if (eq api "orpc")}} import { queryClient, orpc } from "@/utils/orpc"; {{/if}} {{#if (eq api "trpc")}} import { queryClient, trpc } from "@/utils/trpc"; {{/if}} export default function Home() { {{#if (eq api "orpc")}} const healthCheck = useQuery(orpc.healthCheck.queryOptions()); const privateData = useQuery(orpc.privateData.queryOptions()); {{/if}} {{#if (eq api "trpc")}} const healthCheck = useQuery(trpc.healthCheck.queryOptions()); const privateData = useQuery(trpc.privateData.queryOptions()); {{/if}} const { data: session } = authClient.useSession(); return ( <Container> <ScrollView className="flex-1"> <View className="px-4"> <Text className="font-mono text-foreground text-3xl font-bold mb-4"> BETTER T STACK </Text> {session?.user ? ( <View className="mb-6 p-4 bg-card rounded-lg border border-border"> <View className="flex-row justify-between items-center mb-2"> <Text className="text-foreground text-base"> Welcome,{" "} <Text className="font-medium">{session.user.name}</Text> </Text> </View> <Text className="text-muted-foreground text-sm mb-4"> {session.user.email} </Text> <TouchableOpacity className="bg-destructive py-2 px-4 rounded-md self-start" onPress={() => { authClient.signOut(); queryClient.invalidateQueries(); }} > <Text className="text-white font-medium">Sign Out</Text> </TouchableOpacity> </View> ) : null} <View className="mb-6 rounded-lg border border-border p-4"> <Text className="mb-3 font-medium text-foreground">API Status</Text> <View className="flex-row items-center gap-2"> <View className={\`h-3 w-3 rounded-full \${ healthCheck.data ? "bg-green-500" : "bg-red-500" }\`} /> <Text className="text-muted-foreground"> {healthCheck.isLoading ? "Checking..." : healthCheck.data ? "Connected to API" : "API Disconnected"} </Text> </View> </View> <View className="mb-6 rounded-lg border border-border p-4"> <Text className="mb-3 font-medium text-foreground"> Private Data </Text> {privateData && ( <View> <Text className="text-muted-foreground"> {privateData.data?.message} </Text> </View> )} </View> {!session?.user && ( <> <SignIn /> <SignUp /> </> )} </View> </ScrollView> </Container> ); } `, type: "text" }, "auth/native/nativewind/components/sign-in.tsx.hbs": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "4c4e7aa2b5" }, content: `import { authClient } from "@/lib/auth-client"; {{#if (eq api "trpc")}} import { queryClient } from "@/utils/trpc"; {{/if}} {{#if (eq api "orpc")}} import { queryClient } from "@/utils/orpc"; {{/if}} import { useState } from "react"; import { ActivityIndicator, Text, TextInput, TouchableOpacity, View, } from "react-native"; export function SignIn() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState<string | null>(null); const handleLogin = async () => { setIsLoading(true); setError(null); await authClient.signIn.email( { email, password, }, { onError: (error) => { setError(error.error?.message || "Failed to sign in"); setIsLoading(false); }, onSuccess: () => { setEmail(""); setPassword(""); queryClient.refetchQueries(); }, onFinished: () => { setIsLoading(false); }, }, ); }; return ( <View className="mt-6 p-4 bg-card rounded-lg border border-border"> <Text className="text-lg font-semibold text-foreground mb-4"> Sign In </Text> {error && ( <View className="mb-4 p-3 bg-destructive/10 rounded-md"> <Text className="text-destructive text-sm">{error}</Text> </View> )} <TextInput className="mb-3 p-4 rounded-md bg-input text-foreground border border-input" placeholder="Email" value={email} onChangeText={setEmail} placeholderTextColor="#9CA3AF" keyboardType="email-address" autoCapitalize="none" /> <TextInput className="mb-4 p-4 rounded-md bg-input text-foreground border border-input" placeholder="Password" value={password} onChangeText={setPassword} placeholderTextColor="#9CA3AF" secureTextEntry /> <TouchableOpacity onPress={handleLogin} disabled={isLoading} className="bg-primary p-4 rounded-md flex-row justify-center items-center" > {isLoading ? ( <ActivityIndicator size="small" color="#fff" /> ) : ( <Text className="text-primary-foreground font-medium">Sign In</Text> )} </TouchableOpacity> </View> ); }`, type: "text" }, "auth/native/nativewind/components/sign-up.tsx.hbs": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "0b0208cf24" }, content: `import { authClient } from "@/lib/auth-client"; {{#if (eq api "trpc")}} import { queryClient } from "@/utils/trpc"; {{/if}} {{#if (eq api "orpc")}} import { queryClient } from "@/utils/orpc"; {{/if}} import { useState } from "react"; import { ActivityIndicator, Text, TextInput, TouchableOpacity, View, } from "react-native"; export function SignUp() { const [name, setName] = useState(""); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState<string | null>(null); const handleSignUp = async () => { setIsLoading(true); setError(null); await authClient.signUp.email( { name, email, password, }, { onError: (error) => { setError(error.error?.message || "Failed to sign up"); setIsLoading(false); }, onSuccess: () => { setName(""); setEmail(""); setPassword(""); queryClient.refetchQueries(); }, onFinished: () => { setIsLoading(false); }, }, ); }; return ( <View className="mt-6 p-4 bg-card rounded-lg border border-border"> <Text className="text-lg font-semibold text-foreground mb-4"> Create Account </Text> {error && ( <View className="mb-4 p-3 bg-destructive/10 rounded-md"> <Text className="text-destructive text-sm">{error}</Text> </View> )} <TextInput className="mb-3 p-4 rounded-md bg-input text-foreground border border-input" placeholder="Name" value={name} onChangeText={setName} placeholderTextColor="#9CA3AF" /> <TextInput className="mb-3 p-4 rounded-md bg-input text-foreground border border-input" placeholder="Email" value={email} onChangeText={setEmail} placeholderTextColor="#9CA3AF" keyboardType="email-address" autoCapitalize="none" /> <TextInput className="mb-4 p-4 rounded-md bg-input text-foreground border border-input" placeholder="Password" value={password} onChangeText={setPassword} placeholderTextColor="#9CA3AF" secureTextEntry /> <TouchableOpacity onPress={handleSignUp} disabled={isLoading} className="bg-primary p-4 rounded-md flex-row justify-center items-center" > {isLoading ? ( <ActivityIndicator size="small" color="#fff" /> ) : ( <Text className="text-primary-foreground font-medium">Sign Up</Text> )} </TouchableOpacity> </View> ); } `, type: "text" }, "auth/native/unistyles/app/(drawer)/index.tsx.hbs": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "60da1070a7" }, content: `import { authClient } from "@/lib/auth-client"; import { useQuery } from "@tanstack/react-query"; import { ScrollView, Text, TouchableOpacity, View } from "react-native"; import { StyleSheet } from "react-native-unistyles"; import { Container } from "@/components/container"; import { SignIn } from "@/components/sign-in"; import { SignUp } from "@/components/sign-up"; {{#if (eq api "orpc")}} import { queryClient, orpc } from "@/utils/orpc"; {{/if}} {{#if (eq api "trpc")}} import { queryClient, trpc } from "@/utils/trpc"; {{/if}} export default function Home() { {{#if (eq api "orpc")}} const healthCheck = useQuery(orpc.healthCheck.queryOptions()); const privateData = useQuery(orpc.privateData.queryOptions()); {{/if}} {{#if (eq api "trpc")}} const healthCheck = useQuery(trpc.healthCheck.queryOptions()); const privateData = useQuery(trpc.privateData.queryOptions()); {{/if}} const { data: session } = authClient.useSession(); return ( <Container> <ScrollView> <View style={styles.pageContainer}> <Text style={styles.headerTitle}>BETTER T STACK</Text> {session?.user ? ( <View style={styles.sessionInfoCard}> <View style={styles.sessionUserRow}> <Text style={styles.welcomeText}> Welcome,{" "} <Text style={styles.userNameText}>{session.user.name}</Text> </Text> </View> <Text style={styles.emailText}>{session.user.email}</Text> <TouchableOpacity style={styles.signOutButton} onPress={() => { authClient.signOut(); queryClient.invalidateQueries(); }} > <Text style={styles.signOutButtonText}>Sign Out</Text> </TouchableOpacity> </View> ) : null} <View style={styles.apiStatusCard}> <Text style={styles.cardTitle}>API Status</Text> <View style={styles.apiStatusRow}> <View style={[ styles.statusIndicatorDot, healthCheck.data ? styles.statusIndicatorGreen : styles.statusIndicatorRed, ]} /> <Text style={styles.mutedText}> {healthCheck.isLoading ? "Checking..." : healthCheck.data ? "Connected to API" : "API Disconnected"} </Text> </View> </View> <View style={styles.privateDataCard}> <Text style={styles.cardTitle}>Private Data</Text> {privateData && ( <View> <Text style={styles.mutedText}> {privateData.data?.message} </Text> </View> )} </View> {!session?.user && ( <> <SignIn /> <SignUp /> </> )} </View> </ScrollView> </Container> ); } const styles = StyleSheet.create((theme) => ({ pageContainer: { paddingHorizontal: 8, }, headerTitle: { color: theme?.colors?.typography, fontSize: 30, fontWeight: "bold", marginBottom: 16, }, sessionInfoCard: { marginBottom: 24, padding: 16, borderRadius: 8, borderWidth: 1, borderColor: theme?.colors?.border, }, sessionUserRow: { flexDirection: "row", justifyContent: "space-between", alignItems: "center", marginBottom: 8, }, welcomeText: { color: theme?.colors?.typography, fontSize: 16, }, userNameText: { fontWeight: "500", color: theme?.colors?.typography, }, emailText: { color: theme?.colors?.typography, fontSize: 14, marginBottom: 16, }, signOutButton: { backgroundColor: theme?.colors?.destructive, paddingVertical: 8, paddingHorizontal: 16, borderRadius: 6, alignSelf: "flex-start", }, signOutButtonText: { fontWeight: "500", }, apiStatusCard: { marginBottom: 24, borderRadius: 8, borderWidth: 1, borderColor: theme?.colors?.border, padding: 16, }, cardTitle: { marginBottom: 12, fontWeight: "500", color: theme?.colors?.typography, }, apiStatusRow: { flexDirection: "row", alignItems: "center", gap: 8, }, statusIndicatorDot: { height: 12, width: 12, borderRadius: 9999, }, statusIndicatorGreen: { backgroundColor: theme.colors.success, }, statusIndicatorRed: { backgroundColor: theme.colors.destructive, }, mutedText: { color: theme?.colors?.typography, }, privateDataCard: { marginBottom: 24, borderRadius: 8, borderWidth: 1, borderColor: theme?.colors?.border, padding: 16, }, })); `, type: "text" }, "auth/native/unistyles/components/sign-in.tsx.hbs": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "b18567e2a0" }, content: `import { authClient } from "@/lib/auth-client"; {{#if (eq api "trpc")}} import { queryClient } from "@/utils/trpc"; {{/if}} {{#if (eq api "orpc")}} import { queryClient } from "@/utils/orpc"; {{/if}} import { useState } from "react"; import { ActivityIndicator, Text, TextInput, TouchableOpacity, View, } from "react-native"; import { StyleSheet } from "react-native-unistyles"; export function SignIn() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState<string | null>(null); const handleLogin = async () => { setIsLoading(true); setError(null); await authClient.signIn.email( { email, password, }, { onError: (error) => { setError(error.error?.message || "Failed to sign in"); setIsLoading(false); }, onSuccess: () => { setEmail(""); setPassword(""); queryClient.refetchQueries(); }, onFinished: () => { setIsLoading(false); }, }, ); }; return ( <View style={styles.container}> <Text style={styles.title}>Sign In</Text> {error && ( <View style={styles.errorContainer}> <Text style={styles.errorText}>{error}</Text> </View> )} <TextInput style={styles.input} placeholder="Email" value={email} onChangeText={setEmail} keyboardType="email-address" autoCapitalize="none" /> <TextInput style={styles.input} placeholder="Password" value={password} onChangeText={setPassword} secureTextEntry /> <TouchableOpacity onPress={handleLogin} disabled={isLoading} style={styles.button} > {isLoading ? ( <ActivityIndicator size="small" color="#fff" /> ) : ( <Text style={styles.buttonText}>Sign In</Text> )} </TouchableOpacity> </View> ); } const styles = StyleSheet.create((theme) => ({ container: { marginTop: 24, padding: 16, borderRadius: 8, borderWidth: 1, borderColor: theme.colors.border, }, title: { fontSize: 18, fontWeight: "600", color: theme.colors.typography, marginBottom: 16, }, errorContainer: { marginBottom: 16, padding: 12, borderRadius: 6, }, errorText: { color: theme.colors.destructive, fontSize: 14, }, input: { marginBottom: 12, padding: 16, borderRadius: 6, color: theme.colors.typography, borderWidth: 1, borderColor: theme.colors.border, }, button: { backgroundColor: theme.colors.primary, padding: 16, borderRadius: 6, flexDirection: "row", justifyContent: "center", alignItems: "center", }, buttonText: { fontWeight: "500", }, })); `, type: "text" }, "auth/native/unistyles/components/sign-up.tsx.hbs": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "6d011348a6" }, content: `import { authClient } from "@/lib/auth-client"; {{#if (eq api "trpc")}} import { queryClient } from "@/utils/trpc"; {{/if}} {{#if (eq api "orpc")}} import { queryClient } from "@/utils/orpc"; {{/if}} import { useState } from "react"; import { ActivityIndicator, Text, TextInput, TouchableOpacity, View, } from "react-native"; import { StyleSheet } from "react-native-unistyles"; export function SignUp() { const [name, setName] = useState(""); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState<string | null>(null); const handleSignUp = async () => { setIsLoading(true); setError(null); await authClient.signUp.email( { name, email, password, }, { onError: (error) => { setError(error.error?.message || "Failed to sign up"); setIsLoading(false); }, onSuccess: () => { setName(""); setEmail(""); setPassword(""); queryClient.refetchQueries(); }, onFinished: () => { setIsLoading(false); }, }, ); }; return ( <View style={styles.container}> <Text style={styles.title}>Create Account</Text> {error && ( <View style={styles.errorContainer}> <Text style={styles.errorText}>{error}</Text> </View> )} <TextInput style={styles.input} placeholder="Name" value={name} onChangeText={setName} /> <TextInput style={styles.input} placeholder="Email" value={email} onChangeText={setEmail} keyboardType="email-address" autoCapitalize="none" /> <TextInput style={styles.inputLast} placeholder="Password" value={password} onChangeText={setPassword} secureTextEntry /> <TouchableOpacity onPress={handleSignUp} disabled={isLoading} style={styles.button} > {isLoading ? ( <ActivityIndicator size="small" color="#fff" /> ) : ( <Text style={styles.buttonText}>Sign Up</Text> )} </TouchableOpacity> </View> ); } const styles = StyleSheet.create((theme) => ({ container: { marginTop: 24, padding: 16, borderRadius: 8, borderWidth: 1, borderColor: theme.colors.border, }, title: { fontSize: 18, fontWeight: "600", color: theme.colors.typography, marginBottom: 16, }, errorContainer: { marginBottom: 16, padding: 12, borderRadius: 6, }, errorText: { color: theme.colors.destructive, fontSize: 14, }, input: { marginBottom: 12, padding: 16, borderRadius: 6, color: theme.colors.typography, borderWidth: 1, borderColor: theme.colors.border, }, inputLast: { marginBottom: 16, padding: 16, borderRadius: 6, color: theme.colors.typography, borderWidth: 1, borderColor: theme.colors.border, }, button: { backgroundColor: theme.colors.primary, padding: 16, borderRadius: 6, flexDirection: "row", justifyContent: "center", alignItems: "center", }, buttonText: { fontWeight: "500", }, })); `, type: "text" }, "auth/server/base/src/lib/auth.ts.hbs": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "70bcb75db7" }, content: `{{#if (eq orm "prisma")}} import { betterAuth } from "better-auth"; import { prismaAdapter } from "better-auth/adapters/prisma"; {{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}} import { expo } from "@better-auth/expo"; {{/if}} import prisma from "../../prisma"; export const auth = betterAuth({ database: prismaAdapter(prisma, { {{#if (eq database "postgres")}}provider: "postgresql"{{/if}} {{#if (eq database "sqlite")}}provider: "sqlite"{{/if}} {{#if (eq database "mysql")}}provider: "mysql"{{/if}} {{#if (eq database "mongodb")}}provider: "mongodb"{{/if}} }), trustedOrigins: [ process.env.CORS_ORIGIN || "", {{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}} "my-better-t-app://", {{/if}} ], emailAndPassword: { enabled: true, } {{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}} , plugins: [expo()] {{/if}} }); {{/if}} {{#if (eq orm "drizzle")}} {{#if (or (eq runtime "bun") (eq runtime "node"))}} import { betterAuth } from "better-auth"; import { drizzleAdapter } from "better-auth/adapters/drizzle"; {{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}} import { expo } from "@better-auth/expo"; {{/if}} import { db } from "../db"; import * as schema from "../db/schema/auth"; export const auth = betterAuth({ database: drizzleAdapter(db, { {{#if (eq database "postgres")}}provider: "pg",{{/if}} {{#if (eq database "sqlite")}}provider: "sqlite",{{/if}} {{#if (eq database "mysql")}}provider: "mysql",{{/if}} schema: schema, }), trustedOrigins: [ process.env.CORS_ORIGIN || "", {{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}} "my-better-t-app://", {{/if}} ], emailAndPassword: { enabled: true, }, secret: process.env.BETTER_AUTH_SECRET, baseURL: process.env.BETTER_AUTH_URL, {{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}} plugins: [expo()], {{/if}} }); {{/if}} {{#if (eq runtime "workers")}} import { betterAuth } from "better-auth"; import { drizzleAdapter } from "better-auth/adapters/drizzle"; {{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}} import { expo } from "@better-auth/expo"; {{/if}} import { db } from "@/db"; import * as schema from "../db/schema/auth"; import { env } from "cloudflare:workers"; export const auth = betterAuth({ database: drizzleAdapter(db, { {{#if (eq database "postgres")}}provider: "pg",{{/if}} {{#if (eq database "sqlite")}}provider: "sqlite",{{/if}} {{#if (eq database "mysql")}}provider: "mysql",{{/if}} schema: schema, }), trustedOrigins: [env.CORS_ORIGIN], emailAndPassword: { enabled: true, }, secret: env.BETTER_AUTH_SECRET, baseURL: env.BETTER_AUTH_URL, {{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}} plugins: [expo()], {{/if}} }); {{/if}} {{/if}} {{#if (eq orm "mongoose")}} import { betterAuth } from "better-auth"; import { mongodbAdapter } from "better-auth/adapters/mongodb"; {{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}} import { expo } from "@better-auth/expo"; {{/if}} import { client } from "../db"; export const auth = betterAuth({ database: mongodbAdapter(client), trustedOrigins: [ process.env.CORS_ORIGIN || "", {{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}} "my-better-t-app://", {{/if}} ], emailAndPassword: { enabled: true, } {{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}} , plugins: [expo()] {{/if}} }); {{/if}} {{#if (eq orm "none")}} import { betterAuth } from "better-auth"; {{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}} import { expo } from "@better-auth/expo"; {{/if}} export const auth = betterAuth({ database: "", // Invalid configuration trustedOrigins: [ process.env.CORS_ORIGIN || "", {{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}} "my-better-t-app://", {{/if}} ], emailAndPassword: { enabled: true, } {{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}} , plugins: [expo()] {{/if}} }); {{/if}} `, type: "text" }, "auth/server/db/drizzle/mysql/src/db/schema/auth.ts": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "f865fa9316" }, content: `import { mysqlTable, varchar, text, timestamp, boolean, } from "drizzle-orm/mysql-core"; export const user = mysqlTable("user", { id: varchar("id", { length: 36 }).primaryKey(), name: text("name").notNull(), email: varchar("email", { length: 255 }).notNull().unique(), emailVerified: boolean("email_verified").notNull(), image: text("image"), createdAt: timestamp("created_at").notNull(), updatedAt: timestamp("updated_at").notNull(), }); export const session = mysqlTable("session", { id: varchar("id", { length: 36 }).primaryKey(), expiresAt: timestamp("expires_at").notNull(), token: varchar("token", { length: 255 }).notNull().unique(), createdAt: timestamp("created_at").notNull(), updatedAt: timestamp("updated_at").notNull(), ipAddress: text("ip_address"), userAgent: text("user_agent"), userId: varchar("user_id", { length: 36 }) .notNull() .references(() => user.id, { onDelete: "cascade" }), }); export const account = mysqlTable("account", { id: varchar("id", { length: 36 }).primaryKey(), accountId: text("account_id").notNull(), providerId: text("provider_id").notNull(), userId: varchar("user_id", { length: 36 }) .notNull() .references(() => user.id, { onDelete: "cascade" }), accessToken: text("access_token"), refreshToken: text("refresh_token"), idToken: text("id_token"), accessTokenExpiresAt: timestamp("access_token_expires_at"), refreshTokenExpiresAt: timestamp("refresh_token_expires_at"), scope: text("scope"), password: text("password"), createdAt: timestamp("created_at").notNull(), updatedAt: timestamp("updated_at").notNull(), }); export const verification = mysqlTable("verification", { id: varchar("id", { length: 36 }).primaryKey(), identifier: text("identifier").notNull(), value: text("value").notNull(), expiresAt: timestamp("expires_at").notNull(), createdAt: timestamp("created_at"), updatedAt: timestamp("updated_at"), }); `, type: "text" }, "auth/server/db/drizzle/postgres/src/db/schema/auth.ts": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "11be4c3757" }, content: `import { pgTable, text, timestamp, boolean, serial } from "drizzle-orm/pg-core"; export const user = pgTable("user", { id: text("id").primaryKey(), name: text('name').notNull(), email: text('email').notNull().unique(), emailVerified: boolean('email_verified').notNull(), image: text('image'), createdAt: timestamp('created_at').notNull(), updatedAt: timestamp('updated_at').notNull() }); export const session = pgTable("session", { id: text("id").primaryKey(), expiresAt: timestamp('expires_at').notNull(), token: text('token').notNull().unique(), createdAt: timestamp('created_at').notNull(), updatedAt: timestamp('updated_at').notNull(), ipAddress: text('ip_address'), userAgent: text('user_agent'), userId: text('user_id').notNull().references(()=> user.id, { onDelete: 'cascade' }) }); export const account = pgTable("account", { id: text("id").primaryKey(), accountId: text('account_id').notNull(), providerId: text('provider_id').notNull(), userId: text('user_id').notNull().references(()=> user.id, { onDelete: 'cascade' }), accessToken: text('access_token'), refreshToken: text('refresh_token'), idToken: text('id_token'), accessTokenExpiresAt: timestamp('access_token_expires_at'), refreshTokenExpiresAt: timestamp('refresh_token_expires_at'), scope: text('scope'), password: text('password'), createdAt: timestamp('created_at').notNull(), updatedAt: timestamp('updated_at').notNull() }); export const verification = pgTable("verification", { id: text("id").primaryKey(), identifier: text('identifier').notNull(), value: text('value').notNull(), expiresAt: timestamp('expires_at').notNull(), createdAt: timestamp('created_at'), updatedAt: timestamp('updated_at') }); `, type: "text" }, "auth/server/db/drizzle/sqlite/src/db/schema/auth.ts": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "2fd698c3c5" }, content: `import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core"; export const user = sqliteTable("user", { id: text("id").primaryKey(), name: text("name").notNull(), email: text("email").notNull().unique(), emailVerified: integer("email_verified", { mode: "boolean" }).notNull(), image: text("image"), createdAt: integer("created_at", { mode: "timestamp" }).notNull(), updatedAt: integer("updated_at", { mode: "timestamp" }).notNull(), }); export const session = sqliteTable("session", { id: text("id").primaryKey(), expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(), token: text("token").notNull().unique(), createdAt: integer("created_at", { mode: "timestamp" }).notNull(), updatedAt: integer("updated_at", { mode: "timestamp" }).notNull(), ipAddress: text("ip_address"), userAgent: text("user_agent"), userId: text("user_id") .notNull() .references(() => user.id), }); export const account = sqliteTable("account", { id: text("id").primaryKey(), accountId: text("account_id").notNull(), providerId: text("provider_id").notNull(), userId: text("user_id") .notNull() .references(() => user.id), accessToken: text("access_token"), refreshToken: text("refresh_token"), idToken: text("id_token"), accessTokenExpiresAt: integer("access_token_expires_at", { mode: "timestamp", }), refreshTokenExpiresAt: integer("refresh_token_expires_at", { mode: "timestamp", }), scope: text("scope"), password: text("password"), createdAt: integer("created_at", { mode: "timestamp" }).notNull(), updatedAt: integer("updated_at", { mode: "timestamp" }).notNull(), }); export const verification = sqliteTable("verification", { id: text("id").primaryKey(), identifier: text("identifier").notNull(), value: text("value").notNull(), expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(), createdAt: integer("created_at", { mode: "timestamp" }), updatedAt: integer("updated_at", { mode: "timestamp" }), }); `, type: "text" }, "auth/server/db/mongoose/mongodb/src/db/models/auth.model.ts": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "844c2e8227" }, content: `import mongoose from 'mongoose'; const { Schema, model } = mongoose; const userSchema = new Schema( { _id: { type: String }, name: { type: String, required: true }, email: { type: String, required: true, unique: true }, emailVerified: { type: Boolean, required: true }, image: { type: String }, createdAt: { type: Date, required: true }, updatedAt: { type: Date, required: true }, }, { collection: 'user' } ); const sessionSchema = new Schema( { _id: { type: String }, expiresAt: { type: Date, required: true }, token: { type: String, required: true, unique: true }, createdAt: { type: Date, required: true }, updatedAt: { type: Date, required: true }, ipAddress: { type: String }, userAgent: { type: String }, userId: { type: String, ref: 'User', required: true }, }, { collection: 'session' } ); const accountSchema = new Schema( { _id: { type: String }, accountId: { type: String, required: true }, providerId: { type: String, required: true }, userId: { type: String, ref: 'User', required: true }, accessToken: { type: String }, refreshToken: { type: String }, idToken: { type: String }, accessTokenExpiresAt: { type: Date }, refreshTokenExpiresAt: { type: Date }, scope: { type: String }, password: { type: String }, createdAt: { type: Date, required: true }, updatedAt: { type: Date, required: true }, }, { collection: 'account' } ); const verificationSchema = new Schema( { _id: { type: String }, identifier: { type: String, required: true }, value: { type: String, required: true }, expiresAt: { type: Date, required: true }, createdAt: { type: Date }, updatedAt: { type: Date }, }, { collection: 'verification' } ); const User = model('User', userSchema); const Session = model('Session', sessionSchema); const Account = model('Account', accountSchema); const Verification = model('Verification', verificationSchema); export { User, Session, Account, Verification }; `, type: "text" }, "auth/server/db/prisma/mongodb/prisma/schema/auth.prisma": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "ef642790d1" }, content: `model User { id String @id @map("_id") name String email String emailVerified Boolean image String? createdAt DateTime updatedAt DateTime sessions Session[] accounts Account[] @@unique([email]) @@map("user") } model Session { id String @id @map("_id") expiresAt DateTime token String createdAt DateTime updatedAt DateTime ipAddress String? userAgent String? userId String user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@unique([token]) @@map("session") } model Account { id String @id @map("_id") accountId String providerId String userId String user User @relation(fields: [userId], references: [id], onDelete: Cascade) accessToken String? refreshToken String? idToken String? accessTokenExpiresAt DateTime? refreshTokenExpiresAt DateTime? scope String? password String? createdAt DateTime updatedAt DateTime @@map("account") } model Verification { id String @id @map("_id") identifier String value String expiresAt DateTime createdAt DateTime? updatedAt DateTime? @@map("verification") } `, type: "text" }, "auth/server/db/prisma/mysql/prisma/schema/auth.prisma": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "f747cb428d" }, content: `model User { id String @id name String @db.Text email String emailVerified Boolean image String? @db.Text createdAt DateTime updatedAt DateTime sessions Session[] accounts Account[] @@unique([email]) @@map("user") } model Session { id String @id expiresAt DateTime token String createdAt DateTime updatedAt DateTime ipAddress String? @db.Text userAgent String? @db.Text userId String user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@unique([token]) @@map("session") } model Account { id String @id accountId String @db.Text providerId String @db.Text userId String user User @relation(fields: [userId], references: [id], onDelete: Cascade) accessToken String? @db.Text refreshToken String? @db.Text idToken String? @db.Text accessTokenExpiresAt DateTime? refreshTokenExpiresAt DateTime? scope String? @db.Text password String? @db.Text createdAt DateTime updatedAt DateTime @@map("account") } model Verification { id String @id identifier String @db.Text value String @db.Text expiresAt DateTime createdAt DateTime? updatedAt DateTime? @@map("verification") } `, type: "text" }, "auth/server/db/prisma/postgres/prisma/schema/auth.prisma": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "ef642790d1" }, content: `model User { id String @id @map("_id") name String email String emailVerified Boolean image String? createdAt DateTime updatedAt DateTime sessions Session[] accounts Account[] @@unique([email]) @@map("user") } model Session { id String @id @map("_id") expiresAt DateTime token String createdAt DateTime updatedAt DateTime ipAddress String? userAgent String? userId String user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@unique([token]) @@map("session") } model Account { id String @id @map("_id") accountId String providerId String userId String user User @relation(fields: [userId], references: [id], onDelete: Cascade) accessToken String? refreshToken String? idToken String? accessTokenExpiresAt DateTime? refreshTokenExpiresAt DateTime? scope String? password String? createdAt DateTime updatedAt DateTime @@map("account") } model Verification { id String @id @map("_id") identifier String value String expiresAt DateTime createdAt DateTime? updatedAt DateTime? @@map("verification") } `, type: "text" }, "auth/server/db/prisma/sqlite/prisma/schema/auth.prisma": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "ef642790d1" }, content: `model User { id String @id @map("_id") name String email String emailVerified Boolean image String? createdAt DateTime updatedAt DateTime sessions Session[] accounts Account[] @@unique([email]) @@map("user") } model Session { id String @id @map("_id") expiresAt DateTime token String createdAt DateTime updatedAt DateTime ipAddress String? userAgent String? userId String user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@unique([token]) @@map("session") } model Account { id String @id @map("_id") accountId String providerId String userId String user User @relation(fields: [userId], references: [id], onDelete: Cascade) accessToken String? refreshToken String? idToken String? accessTokenExpiresAt DateTime? refreshTokenExpiresAt DateTime? scope String? password String? createdAt DateTime updatedAt DateTime @@map("account") } model Verification { id String @id @map("_id") identifier String value String expiresAt DateTime createdAt DateTime? updatedAt DateTime? @@map("verification") } `, type: "text" }, "auth/server/next/src/app/api/auth/[...all]/route.ts": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "1eeae5d0e3" }, content: `import { auth } from "@/lib/auth"; import { toNextJsHandler } from "better-auth/next-js"; export const { GET, POST } = toNextJsHandler(auth.handler); `, type: "text" }, "auth/web/nuxt/app/components/SignInForm.vue": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "4d70f0e8c7" }, content: `<script setup lang="ts"> import z from 'zod/v4' const {$authClient} = useNuxtApp() import type { FormSubmitEvent } from '#ui/types' const emit = defineEmits(['switchToSignUp']) const toast = useToast() const loading = ref(false) const schema = z.object({ email: z.email('Invalid email address'), password: z.string().min(8, 'Password must be at least 8 characters'), }) type Schema = z.output<typeof schema> const state = reactive({ email: '', password: '', }) async function onSubmit (event: FormSubmitEvent<Schema>) { loading.value = true try { await $authClient.signIn.email( { email: event.data.email, password: event.data.password, }, { onSuccess: () => { toast.add({ title: 'Sign in successful' }) navigateTo('/dashboard', { replace: true }) }, onError: (error) => { toast.add({ title: 'Sign in failed', description: error.error.message }) }, }, ) } catch (error: any) { toast.add({ title: 'An unexpected error occurred', description: error.message || 'Please try again.' }) } finally { loading.value = false } } <\/script> <template> <div class="mx-auto w-full mt-10 max-w-md p-6"> <h1 class="mb-6 text-center text-3xl font-bold">Welcome Back</h1> <UForm :schema="schema" :state="state" class="space-y-4" @submit="onSubmit"> <UFormField label="Email" name="email"> <UInput v-model="state.email" type="email" class="w-full" /> </UFormField> <UFormField label="Password" name="password"> <UInput v-model="state.password" type="password" class="w-full" /> </UFormField> <UButton type="submit" block :loading="loading"> Sign In </UButton> </UForm> <div class="mt-4 text-center"> <UButton variant="link" @click="$emit('switchToSignUp')" class="text-primary hover:text-primary-dark" > Need an account? Sign Up </UButton> </div> </div> </template> `, type: "text" }, "auth/web/nuxt/app/components/SignUpForm.vue": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "414fb57522" }, content: `<script setup lang="ts"> import z from 'zod/v4' import type { FormSubmitEvent } from '#ui/types' const {$authClient} = useNuxtApp() const emit = defineEmits(['switchToSignIn']) const toast = useToast() const loading = ref(false) const schema = z.object({ name: z.string().min(2, 'Name must be at least 2 characters'), email: z.email('Invalid email address'), password: z.string().min(8, 'Password must be at least 8 characters'), }) type Schema = z.output<typeof schema> const state = reactive({ name: '', email: '', password: '', }) async function onSubmit (event: FormSubmitEvent<Schema>) { loading.value = true try { await $authClient.signUp.email( { name: event.data.name, email: event.data.email, password: event.data.password, }, { onSuccess: () => { toast.add({ title: 'Sign up successful' }) navigateTo('/dashboard', { replace: true }) }, onError: (error) => { toast.add({ title: 'Sign up failed', description: error.error.message }) }, }, ) } catch (error: any) { toast.add({ title: 'An unexpected error occurred', description: error.message || 'Please try again.' }) } finally { loading.value = false } } <\/script> <template> <div class="mx-auto w-full mt-10 max-w-md p-6"> <h1 class="mb-6 text-center text-3xl font-bold">Create Account</h1> <UForm :schema="schema" :state="state" class="space-y-4" @submit="onSubmit"> <UFormField label="Name" name="name"> <UInput v-model="state.name" class="w-full" /> </UFormField> <UFormField label="Email" name="email"> <UInput v-model="state.email" type="email" class="w-full" /> </UFormField> <UFormField label="Password" name="password"> <UInput v-model="state.password" type="password" class="w-full" /> </UFormField> <UButton type="submit" block :loading="loading"> Sign Up </UButton> </UForm> <div class="mt-4 text-center"> <UButton variant="link" @click="$emit('switchToSignIn')" class="text-primary hover:text-primary-dark" > Already have an account? Sign In </UButton> </div> </div> </template> `, type: "text" }, "auth/web/nuxt/app/components/UserMenu.vue": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "fc4335c0e0" }, content: `<script setup lang="ts"> const {$authClient} = useNuxtApp() const session = $authClient.useSession() const toast = useToast() const handleSignOut = async () => { try { await $authClient.signOut({ fetchOptions: { onSuccess: async () => { toast.add({ title: 'Signed out successfully' }) await navigateTo('/', { replace: true, external: true }) }, onError: (error) => { toast.add({ title: 'Sign out failed', description: error?.error?.message || 'Unknown error'}) } }, }) } catch (error: any) { toast.add({ title: 'An unexpected error occurred during sign out', description: error.message || 'Please try again.'}) } } <\/script> <template> <div> <USkeleton v-if="session.isPending" class="h-9 w-24" /> <UButton v-else-if="!session.data" variant="outline" to="/login"> Sign In </UButton> <UButton v-else variant="solid" icon="i-lucide-log-out" label="Sign out" @click="handleSignOut()" /> </div> </template> `, type: "text" }, "auth/web/nuxt/app/middleware/auth.ts": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "e1df215c73" }, content: `export default defineNuxtRouteMiddleware(async (to, from) => { if (import.meta.server) return const { $authClient } = useNuxtApp() const session = $authClient.useSession() if (session.value.isPending || !session.value) { if (to.path === "/dashboard") { return navigateTo("/login"); } } }); `, type: "text" }, "auth/web/nuxt/app/pages/dashboard.vue": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "c21e12fd96" }, content: `<script setup lang="ts"> import { useQuery } from '@tanstack/vue-query' const {$authClient} = useNuxtApp() definePageMeta({ middleware: ['auth'] }) const { $orpc } = useNuxtApp() const session = $authClient.useSession() const privateData = useQuery($orpc.privateData.queryOptions()) <\/script> <template> <div class="container mx-auto p-4"> <h1 class="text-2xl font-bold mb-4">Dashboard</h1> <div v-if="session?.data?.user"> <p class="mb-2">Welcome {{ session.data.user.name }}</p> </div> <div v-if="privateData.status.value === 'pending'">Loading private data...</div> <div v-else-if="privateData.status.value === 'error'">Error loading private data: {{ privateData.error.value?.message }}</div> <p v-else-if="privateData.data.value">Private Data: {{ privateData.data.value.message }}</p> </div> </template> `, type: "text" }, "auth/web/nuxt/app/pages/login.vue": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "d6c3c73480" }, content: `<script setup lang="ts"> const { $authClient } = useNuxtApp(); import SignInForm from "../../../components/SignInForm.vue"; import SignUpForm from "../../../components/SignUpForm.vue"; const session = $authClient.useSession(); const showSignIn = ref(true); watchEffect(() => { if (!session?.value.isPending && session?.value.data) { navigateTo("/dashboard", { replace: true }); } }); <\/script> <template> <div> <Loader v-if="session.isPending" /> <div v-else-if="!session.data"> <SignInForm v-if="showSignIn" @switch-to-sign-up="showSignIn = false" /> <SignUpForm v-else @switch-to-sign-in="showSignIn = true" /> </div> </div> </template> `, type: "text" }, "auth/web/nuxt/app/plugins/auth-client.ts": { metadata: { updatedAt: "2025-06-17T06:06:35.000Z", updatedHash: "