- Added drizzle configuration for PostgreSQL connection. - Created user schema for the 'demo' table in drizzle. - Implemented database connection and user retrieval in drizzle integration. - Added migration SQL for creating the 'demo' table. - Updated user hooks to use server functions for login and signup. - Refactored user-related functions to use drizzle ORM for database interactions. - Updated routes to utilize new user management functions.
64 lines
1.2 KiB
TypeScript
64 lines
1.2 KiB
TypeScript
import css from "@styles/globals.css?url"
|
|
import type { QueryClient } from "@tanstack/react-query"
|
|
import {
|
|
createRootRouteWithContext,
|
|
HeadContent,
|
|
Scripts
|
|
} from "@tanstack/react-router"
|
|
import { TanStackRouterDevtools } from "@tanstack/react-router-devtools"
|
|
import { HeroUIProvider } from "@/integrations/heroui/provider"
|
|
import { SonnerProvider } from "@/integrations/sonner/provider"
|
|
import { getUser } from "@/lib/server/user"
|
|
|
|
interface MyRouterContext {
|
|
queryClient: QueryClient
|
|
user: null
|
|
}
|
|
|
|
export const Route = createRootRouteWithContext<MyRouterContext>()({
|
|
beforeLoad: async () => {
|
|
const user = await getUser()
|
|
return {
|
|
...user
|
|
}
|
|
},
|
|
head: () => ({
|
|
meta: [
|
|
{
|
|
charSet: "utf-8"
|
|
},
|
|
{
|
|
name: "viewport",
|
|
content: "width=device-width, initial-scale=1"
|
|
},
|
|
{
|
|
title: "TanStack Start Starter"
|
|
}
|
|
],
|
|
links: [
|
|
{
|
|
rel: "stylesheet",
|
|
href: css
|
|
}
|
|
]
|
|
}),
|
|
|
|
shellComponent: RootDocument
|
|
})
|
|
|
|
function RootDocument({ children }: { children: React.ReactNode }) {
|
|
return (
|
|
<html lang="es">
|
|
<head>
|
|
<HeadContent />
|
|
</head>
|
|
<body>
|
|
<HeroUIProvider>{children}</HeroUIProvider>
|
|
<SonnerProvider />
|
|
<TanStackRouterDevtools />
|
|
<Scripts />
|
|
</body>
|
|
</html>
|
|
)
|
|
}
|