create-better-t-stack 1.13.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +100 -186
- package/package.json +72 -67
- package/templates/api/orpc/server/base/src/lib/context.ts.hbs +105 -0
- package/templates/api/orpc/server/base/src/lib/orpc.ts.hbs +17 -0
- package/templates/api/orpc/server/next/src/app/rpc/[...all]/route.ts.hbs +23 -0
- package/templates/api/orpc/web/base/src/utils/orpc.ts.hbs +57 -0
- package/templates/api/trpc/server/base/src/lib/context.ts.hbs +108 -0
- package/{template/with-auth/apps/server/src/lib/trpc.ts → templates/api/trpc/server/base/src/lib/trpc.ts.hbs} +2 -0
- package/templates/api/trpc/web/base/src/utils/trpc.ts.hbs +100 -0
- package/templates/auth/server/base/src/lib/auth.ts.hbs +30 -0
- package/templates/auth/web/base/src/lib/auth-client.ts.hbs +10 -0
- package/{template/with-auth/apps/web-next/src/app/dashboard/page.tsx → templates/auth/web/next/src/app/dashboard/page.tsx.hbs} +10 -0
- package/{template/with-auth/apps/web-react-router/src/routes/dashboard.tsx → templates/auth/web/react-router/src/routes/dashboard.tsx.hbs} +10 -0
- package/{template/with-auth/apps/web-tanstack-router/src/routes/dashboard.tsx → templates/auth/web/tanstack-router/src/routes/dashboard.tsx.hbs} +10 -0
- package/{template/with-auth/apps/web-tanstack-start/src/routes/dashboard.tsx → templates/auth/web/tanstack-start/src/routes/dashboard.tsx.hbs} +15 -0
- package/{template/with-auth/apps/server/src/with-elysia-index.ts → templates/backend/elysia/src/index.ts.hbs} +38 -3
- package/templates/backend/express/src/index.ts.hbs +78 -0
- package/templates/backend/hono/src/index.ts.hbs +105 -0
- package/{template/with-next/apps/server → templates/backend/next}/package.json +0 -2
- package/{template/base/apps/server → templates/backend/server-base}/package.json +0 -1
- package/templates/backend/server-base/src/routers/index.ts.hbs +51 -0
- package/templates/base/package.json +10 -0
- package/templates/examples/todo/server/drizzle/base/src/routers/todo.ts.hbs +79 -0
- package/{template/with-drizzle-sqlite/apps/server → templates/examples/todo/server/drizzle/sqlite}/src/db/schema/todo.ts +2 -2
- package/{template/examples/todo/apps/web-react-router/src/routes/todos.tsx → templates/examples/todo/web/react-router/src/routes/todos.tsx.hbs} +28 -0
- package/{template/examples/todo/apps/web-tanstack-router/src/routes/todos.tsx → templates/examples/todo/web/tanstack-router/src/routes/todos.tsx.hbs} +28 -0
- package/{template/examples/todo/apps/web-tanstack-start/src/routes/todos.tsx → templates/examples/todo/web/tanstack-start/src/routes/todos.tsx.hbs} +33 -0
- package/{template/base/apps/web-next → templates/frontend/next}/package.json +0 -2
- package/{template/base/apps/web-next/src/app/page.tsx → templates/frontend/next/src/app/page.tsx.hbs} +10 -0
- package/{template/base/apps/web-next/src/components/providers.tsx → templates/frontend/next/src/components/providers.tsx.hbs} +12 -0
- package/{template/base/apps/web-react-router → templates/frontend/react-router}/package.json +0 -3
- package/{template/base/apps/web-react-router/src/root.tsx → templates/frontend/react-router/src/root.tsx.hbs} +28 -1
- package/{template/base/apps/web-react-router/src/routes/_index.tsx → templates/frontend/react-router/src/routes/_index.tsx.hbs} +11 -0
- package/templates/frontend/react-router/vite.config.ts.hbs +37 -0
- package/{template/base/apps/web-tanstack-router → templates/frontend/tanstack-router}/package.json +0 -4
- package/{template/base/apps/web-tanstack-router/src/main.tsx → templates/frontend/tanstack-router/src/main.tsx.hbs} +20 -0
- package/{template/base/apps/web-tanstack-router/src/routes/__root.tsx → templates/frontend/tanstack-router/src/routes/__root.tsx.hbs} +48 -0
- package/{template/base/apps/web-tanstack-router/src/routes/index.tsx → templates/frontend/tanstack-router/src/routes/index.tsx.hbs} +10 -0
- package/templates/frontend/tanstack-router/vite.config.ts.hbs +43 -0
- package/{template/base/apps/web-tanstack-start → templates/frontend/tanstack-start}/package.json +0 -3
- package/{template/with-auth/apps/web-tanstack-start/src/router.tsx → templates/frontend/tanstack-start/src/router.tsx.hbs} +29 -3
- package/{template/base/apps/web-tanstack-start/src/routes/__root.tsx → templates/frontend/tanstack-start/src/routes/__root.tsx.hbs} +13 -0
- package/{template/base/apps/web-tanstack-start/src/routes/index.tsx → templates/frontend/tanstack-start/src/routes/index.tsx.hbs} +11 -0
- package/templates/frontend/web-base/src/components/header.tsx.hbs +80 -0
- package/template/base/apps/server/src/lib/trpc.ts +0 -8
- package/template/base/apps/server/src/routers/index.ts +0 -11
- package/template/base/apps/web-base/src/utils/trpc.ts +0 -33
- package/template/base/apps/web-next/src/components/header.tsx +0 -30
- package/template/base/apps/web-next/src/utils/trpc.ts +0 -33
- package/template/base/apps/web-react-router/src/components/header.tsx +0 -31
- package/template/base/apps/web-react-router/vite.config.ts +0 -8
- package/template/base/apps/web-tanstack-router/src/components/header.tsx +0 -31
- package/template/base/apps/web-tanstack-router/vite.config.ts +0 -14
- package/template/base/apps/web-tanstack-start/src/components/header.tsx +0 -27
- package/template/base/apps/web-tanstack-start/src/router.tsx +0 -70
- package/template/base/apps/web-tanstack-start/src/utils/trpc.ts +0 -5
- package/template/base/package.json +0 -18
- package/template/examples/todo/apps/server/src/routers/with-drizzle-todo.ts +0 -34
- package/template/with-auth/apps/server/src/lib/with-elysia-context.ts +0 -18
- package/template/with-auth/apps/server/src/lib/with-express-context.ts +0 -14
- package/template/with-auth/apps/server/src/lib/with-hono-context.ts +0 -18
- package/template/with-auth/apps/server/src/lib/with-next-context.ts +0 -14
- package/template/with-auth/apps/server/src/routers/index.ts +0 -17
- package/template/with-auth/apps/server/src/with-drizzle-mysql-lib/auth.ts +0 -15
- package/template/with-auth/apps/server/src/with-drizzle-postgres-lib/auth.ts +0 -15
- package/template/with-auth/apps/server/src/with-drizzle-sqlite-lib/auth.ts +0 -15
- package/template/with-auth/apps/server/src/with-express-index.ts +0 -34
- package/template/with-auth/apps/server/src/with-hono-index.ts +0 -39
- package/template/with-auth/apps/server/src/with-prisma-mongodb-lib/auth.ts +0 -11
- package/template/with-auth/apps/server/src/with-prisma-mysql-lib/auth.ts +0 -11
- package/template/with-auth/apps/server/src/with-prisma-postgres-lib/auth.ts +0 -11
- package/template/with-auth/apps/server/src/with-prisma-sqlite-lib/auth.ts +0 -11
- package/template/with-auth/apps/web-base/src/lib/auth-client.ts +0 -5
- package/template/with-auth/apps/web-next/src/components/header.tsx +0 -33
- package/template/with-auth/apps/web-next/src/lib/auth-client.ts +0 -5
- package/template/with-auth/apps/web-next/src/utils/trpc.ts +0 -39
- package/template/with-auth/apps/web-react-router/src/components/header.tsx +0 -34
- package/template/with-auth/apps/web-react-router/src/utils/trpc.ts +0 -39
- package/template/with-auth/apps/web-tanstack-router/src/components/header.tsx +0 -34
- package/template/with-auth/apps/web-tanstack-router/src/utils/trpc.ts +0 -39
- package/template/with-auth/apps/web-tanstack-start/src/components/header.tsx +0 -32
- package/template/with-elysia/apps/server/src/index.ts +0 -27
- package/template/with-elysia/apps/server/src/lib/context.ts +0 -13
- package/template/with-express/apps/server/src/index.ts +0 -29
- package/template/with-express/apps/server/src/lib/context.ts +0 -9
- package/template/with-hono/apps/server/src/index.ts +0 -33
- package/template/with-hono/apps/server/src/lib/context.ts +0 -13
- package/template/with-next/apps/server/src/lib/context.ts +0 -9
- /package/{template/with-biome → templates/addons/biome}/biome.json +0 -0
- /package/{template/with-husky → templates/addons/husky}/.husky/pre-commit +0 -0
- /package/{template/with-pwa → templates/addons/pwa}/apps/web/public/logo.png +0 -0
- /package/{template/with-pwa → templates/addons/pwa}/apps/web/pwa-assets.config.ts +0 -0
- /package/{template/base → templates/addons/turborepo}/turbo.json +0 -0
- /package/{template/with-next/apps/server → templates/api/trpc/server/next}/src/app/trpc/[trpc]/route.ts +0 -0
- /package/{template/with-auth/apps → templates/auth}/native/app/(drawer)/index.tsx +0 -0
- /package/{template/with-auth/apps → templates/auth}/native/components/sign-in.tsx +0 -0
- /package/{template/with-auth/apps → templates/auth}/native/components/sign-up.tsx +0 -0
- /package/{template/with-auth/apps → templates/auth}/native/lib/auth-client.ts +0 -0
- /package/{template/with-auth/apps → templates/auth}/native/utils/trpc.ts +0 -0
- /package/{template/with-drizzle-mysql/apps/server → templates/auth/server/db/drizzle/mysql}/src/db/schema/auth.ts +0 -0
- /package/{template/with-drizzle-postgres/apps/server → templates/auth/server/db/drizzle/postgres}/src/db/schema/auth.ts +0 -0
- /package/{template/with-drizzle-sqlite/apps/server → templates/auth/server/db/drizzle/sqlite}/src/db/schema/auth.ts +0 -0
- /package/{template/with-prisma-sqlite/apps/server → templates/auth/server/db/prisma/mongodb}/prisma/schema/auth.prisma +0 -0
- /package/{template/with-prisma-mysql/apps/server → templates/auth/server/db/prisma/mysql}/prisma/schema/auth.prisma +0 -0
- /package/{template/with-prisma-postgres/apps/server → templates/auth/server/db/prisma/postgres}/prisma/schema/auth.prisma +0 -0
- /package/{template/with-prisma-mongodb/apps/server → templates/auth/server/db/prisma/sqlite}/prisma/schema/auth.prisma +0 -0
- /package/{template/with-auth/apps/server/src/with-next-app → templates/auth/server/next/src/app}/api/auth/[...all]/route.ts +0 -0
- /package/{template/with-auth/apps/web-next → templates/auth/web/next}/src/app/login/page.tsx +0 -0
- /package/{template/with-auth/apps/web-next → templates/auth/web/next}/src/components/sign-in-form.tsx +0 -0
- /package/{template/with-auth/apps/web-next → templates/auth/web/next}/src/components/sign-up-form.tsx +0 -0
- /package/{template/with-auth/apps/web-next → templates/auth/web/next}/src/components/theme-provider.tsx +0 -0
- /package/{template/with-auth/apps/web-next → templates/auth/web/next}/src/components/user-menu.tsx +0 -0
- /package/{template/with-auth/apps/web-react-router → templates/auth/web/react-router}/src/components/sign-in-form.tsx +0 -0
- /package/{template/with-auth/apps/web-react-router → templates/auth/web/react-router}/src/components/sign-up-form.tsx +0 -0
- /package/{template/with-auth/apps/web-react-router → templates/auth/web/react-router}/src/components/user-menu.tsx +0 -0
- /package/{template/with-auth/apps/web-react-router → templates/auth/web/react-router}/src/routes/login.tsx +0 -0
- /package/{template/with-auth/apps/web-tanstack-start → templates/auth/web/tanstack-router}/src/components/sign-in-form.tsx +0 -0
- /package/{template/with-auth/apps/web-tanstack-start → templates/auth/web/tanstack-router}/src/components/sign-up-form.tsx +0 -0
- /package/{template/with-auth/apps/web-tanstack-start → templates/auth/web/tanstack-router}/src/components/user-menu.tsx +0 -0
- /package/{template/with-auth/apps/web-tanstack-start → templates/auth/web/tanstack-router}/src/routes/login.tsx +0 -0
- /package/{template/with-auth/apps/web-tanstack-router → templates/auth/web/tanstack-start}/src/components/sign-in-form.tsx +0 -0
- /package/{template/with-auth/apps/web-tanstack-router → templates/auth/web/tanstack-start}/src/components/sign-up-form.tsx +0 -0
- /package/{template/with-auth/apps/web-tanstack-router → templates/auth/web/tanstack-start}/src/components/user-menu.tsx +0 -0
- /package/{template/with-auth/apps/web-tanstack-router → templates/auth/web/tanstack-start}/src/routes/login.tsx +0 -0
- /package/{template/with-next/apps/server → templates/backend/next}/next-env.d.ts +0 -0
- /package/{template/with-next/apps/server → templates/backend/next}/next.config.ts +0 -0
- /package/{template/with-next/apps/server → templates/backend/next}/src/app/route.ts +0 -0
- /package/{template/with-next/apps/server → templates/backend/next}/src/middleware.ts +0 -0
- /package/{template/with-next/apps/server → templates/backend/next}/tsconfig.json +0 -0
- /package/{template/base/apps/server → templates/backend/server-base}/_gitignore +0 -0
- /package/{template/base/apps/server → templates/backend/server-base}/tsconfig.json +0 -0
- /package/{template → templates}/base/_gitignore +0 -0
- /package/{template/with-drizzle-mysql/apps/server → templates/db/drizzle/mysql}/drizzle.config.ts +0 -0
- /package/{template/with-drizzle-mysql/apps/server → templates/db/drizzle/mysql}/src/db/index.ts +0 -0
- /package/{template/with-drizzle-postgres/apps/server → templates/db/drizzle/postgres}/drizzle.config.ts +0 -0
- /package/{template/with-drizzle-postgres/apps/server → templates/db/drizzle/postgres}/src/db/index.ts +0 -0
- /package/{template/with-drizzle-sqlite/apps/server → templates/db/drizzle/sqlite}/drizzle.config.ts +0 -0
- /package/{template/with-drizzle-sqlite/apps/server → templates/db/drizzle/sqlite}/src/db/index.ts +0 -0
- /package/{template/with-prisma-sqlite/apps/server → templates/db/prisma/mongodb}/prisma/index.ts +0 -0
- /package/{template/with-prisma-mongodb/apps/server → templates/db/prisma/mongodb}/prisma/schema/schema.prisma +0 -0
- /package/{template/with-prisma-postgres/apps/server → templates/db/prisma/mysql}/prisma/index.ts +0 -0
- /package/{template/with-prisma-mysql/apps/server → templates/db/prisma/mysql}/prisma/schema/schema.prisma +0 -0
- /package/{template/with-prisma-mysql/apps/server → templates/db/prisma/postgres}/prisma/index.ts +0 -0
- /package/{template/with-prisma-postgres/apps/server → templates/db/prisma/postgres}/prisma/schema/schema.prisma +0 -0
- /package/{template/with-prisma-mongodb/apps/server → templates/db/prisma/sqlite}/prisma/index.ts +0 -0
- /package/{template/with-prisma-sqlite/apps/server → templates/db/prisma/sqlite}/prisma/schema/schema.prisma +0 -0
- /package/{template/examples/ai/apps/web-react-router → templates/examples/ai/apps/react-router}/src/routes/ai.tsx +0 -0
- /package/{template/examples/ai/apps/web-tanstack-start → templates/examples/ai/apps/tanstack-router}/src/routes/ai.tsx +0 -0
- /package/{template/examples/ai/apps/web-tanstack-router → templates/examples/ai/apps/tanstack-start}/src/routes/ai.tsx +0 -0
- /package/{template/with-drizzle-mysql/apps/server → templates/examples/todo/server/drizzle/mysql}/src/db/schema/todo.ts +0 -0
- /package/{template/with-drizzle-postgres/apps/server → templates/examples/todo/server/drizzle/postgres}/src/db/schema/todo.ts +0 -0
- /package/{template/examples/todo/apps/server/src/routers/with-prisma-todo.ts → templates/examples/todo/server/prisma/base/trpc/src/routers/todo.ts} +0 -0
- /package/{template/with-prisma-mongodb/apps/server → templates/examples/todo/server/prisma/mongodb}/prisma/schema/todo.prisma +0 -0
- /package/{template/with-prisma-sqlite/apps/server → templates/examples/todo/server/prisma/mysql}/prisma/schema/todo.prisma +0 -0
- /package/{template/with-prisma-postgres/apps/server → templates/examples/todo/server/prisma/postgres}/prisma/schema/todo.prisma +0 -0
- /package/{template/with-prisma-mysql/apps/server → templates/examples/todo/server/prisma/sqlite}/prisma/schema/todo.prisma +0 -0
- /package/{template/with-pnpm → templates/extras}/pnpm-workspace.yaml +0 -0
- /package/{template/base/apps → templates/frontend}/native/_gitignore +0 -0
- /package/{template/base/apps → templates/frontend}/native/app/(drawer)/(tabs)/_layout.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/app/(drawer)/(tabs)/index.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/app/(drawer)/(tabs)/two.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/app/(drawer)/_layout.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/app/(drawer)/index.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/app/+html.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/app/+not-found.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/app/_layout.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/app/modal.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/app-env.d.ts +0 -0
- /package/{template/base/apps → templates/frontend}/native/app.json +0 -0
- /package/{template/base/apps → templates/frontend}/native/assets/adaptive-icon.png +0 -0
- /package/{template/base/apps → templates/frontend}/native/assets/favicon.png +0 -0
- /package/{template/base/apps → templates/frontend}/native/assets/icon.png +0 -0
- /package/{template/base/apps → templates/frontend}/native/assets/splash.png +0 -0
- /package/{template/base/apps → templates/frontend}/native/babel.config.js +0 -0
- /package/{template/base/apps → templates/frontend}/native/components/container.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/components/header-button.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/components/tabbar-icon.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/global.css +0 -0
- /package/{template/base/apps → templates/frontend}/native/lib/android-navigation-bar.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/lib/constants.ts +0 -0
- /package/{template/base/apps → templates/frontend}/native/lib/use-color-scheme.ts +0 -0
- /package/{template/base/apps → templates/frontend}/native/metro.config.js +0 -0
- /package/{template/base/apps → templates/frontend}/native/package.json +0 -0
- /package/{template/base/apps → templates/frontend}/native/tailwind.config.js +0 -0
- /package/{template/base/apps → templates/frontend}/native/tsconfig.json +0 -0
- /package/{template/base/apps → templates/frontend}/native/utils/trpc.ts +0 -0
- /package/{template/base/apps/web-next → templates/frontend/next}/next-env.d.ts +0 -0
- /package/{template/base/apps/web-next → templates/frontend/next}/next.config.ts +0 -0
- /package/{template/base/apps/web-next → templates/frontend/next}/postcss.config.mjs +0 -0
- /package/{template/base/apps/web-next → templates/frontend/next}/src/app/favicon.ico +0 -0
- /package/{template/base/apps/web-next → templates/frontend/next}/src/app/layout.tsx +0 -0
- /package/{template/base/apps/web-next → templates/frontend/next}/src/components/mode-toggle.tsx +0 -0
- /package/{template/base/apps/web-next → templates/frontend/next}/src/components/theme-provider.tsx +0 -0
- /package/{template/base/apps/web-next → templates/frontend/next}/tsconfig.json +0 -0
- /package/{template/base/apps/web-react-router → templates/frontend/react-router}/public/favicon.ico +0 -0
- /package/{template/base/apps/web-react-router → templates/frontend/react-router}/react-router.config.ts +0 -0
- /package/{template/base/apps/web-tanstack-router → templates/frontend/react-router}/src/components/mode-toggle.tsx +0 -0
- /package/{template/base/apps/web-tanstack-router → templates/frontend/react-router}/src/components/theme-provider.tsx +0 -0
- /package/{template/base/apps/web-react-router → templates/frontend/react-router}/src/routes.ts +0 -0
- /package/{template/base/apps/web-react-router → templates/frontend/react-router}/tsconfig.json +0 -0
- /package/{template/base/apps/web-tanstack-router → templates/frontend/tanstack-router}/index.html +0 -0
- /package/{template/base/apps/web-react-router → templates/frontend/tanstack-router}/src/components/mode-toggle.tsx +0 -0
- /package/{template/base/apps/web-react-router → templates/frontend/tanstack-router}/src/components/theme-provider.tsx +0 -0
- /package/{template/base/apps/web-tanstack-router → templates/frontend/tanstack-router}/tsconfig.json +0 -0
- /package/{template/base/apps/web-tanstack-start → templates/frontend/tanstack-start}/app.config.ts +0 -0
- /package/{template/base/apps/web-tanstack-start → templates/frontend/tanstack-start}/public/robots.txt +0 -0
- /package/{template/base/apps/web-tanstack-start → templates/frontend/tanstack-start}/src/api.ts +0 -0
- /package/{template/base/apps/web-tanstack-start → templates/frontend/tanstack-start}/src/client.tsx +0 -0
- /package/{template/base/apps/web-tanstack-start → templates/frontend/tanstack-start}/src/ssr.tsx +0 -0
- /package/{template/base/apps/web-tanstack-start → templates/frontend/tanstack-start}/tsconfig.json +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/_gitignore +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/components.json +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/components/loader.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/components/ui/button.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/components/ui/card.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/components/ui/checkbox.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/components/ui/dropdown-menu.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/components/ui/input.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/components/ui/label.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/components/ui/skeleton.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/components/ui/sonner.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/index.css +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/lib/utils.ts +0 -0
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { NavLink } from "react-router";
|
|
2
|
-
import { ModeToggle } from "./mode-toggle";
|
|
3
|
-
|
|
4
|
-
export default function Header() {
|
|
5
|
-
const links = [
|
|
6
|
-
{ to: "/", label: "Home" },
|
|
7
|
-
];
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<div>
|
|
11
|
-
<div className="flex flex-row items-center justify-between px-2 py-1">
|
|
12
|
-
<nav className="flex gap-4 text-lg">
|
|
13
|
-
{links.map(({ to, label }) => (
|
|
14
|
-
<NavLink
|
|
15
|
-
key={to}
|
|
16
|
-
to={to}
|
|
17
|
-
className={({ isActive }) => (isActive ? "font-bold" : "")}
|
|
18
|
-
end
|
|
19
|
-
>
|
|
20
|
-
{label}
|
|
21
|
-
</NavLink>
|
|
22
|
-
))}
|
|
23
|
-
</nav>
|
|
24
|
-
<div className="flex items-center gap-2">
|
|
25
|
-
<ModeToggle />
|
|
26
|
-
</div>
|
|
27
|
-
</div>
|
|
28
|
-
<hr />
|
|
29
|
-
</div>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { reactRouter } from "@react-router/dev/vite";
|
|
2
|
-
import tailwindcss from "@tailwindcss/vite";
|
|
3
|
-
import { defineConfig } from "vite";
|
|
4
|
-
import tsconfigPaths from "vite-tsconfig-paths";
|
|
5
|
-
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
plugins: [tailwindcss(), reactRouter(), tsconfigPaths()],
|
|
8
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Link } from "@tanstack/react-router";
|
|
2
|
-
import { ModeToggle } from "./mode-toggle";
|
|
3
|
-
|
|
4
|
-
export default function Header() {
|
|
5
|
-
const links = [
|
|
6
|
-
{ to: "/", label: "Home" },
|
|
7
|
-
];
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<div>
|
|
11
|
-
<div className="flex flex-row items-center justify-between px-2 py-1">
|
|
12
|
-
<nav className="flex gap-4 text-lg">
|
|
13
|
-
{links.map(({ to, label }) => (
|
|
14
|
-
<Link
|
|
15
|
-
key={to}
|
|
16
|
-
to={to}
|
|
17
|
-
activeProps={{ className: "font-bold" }}
|
|
18
|
-
activeOptions={{ exact: true }}
|
|
19
|
-
>
|
|
20
|
-
{label}
|
|
21
|
-
</Link>
|
|
22
|
-
))}
|
|
23
|
-
</nav>
|
|
24
|
-
<div className="flex items-center gap-2">
|
|
25
|
-
<ModeToggle />
|
|
26
|
-
</div>
|
|
27
|
-
</div>
|
|
28
|
-
<hr />
|
|
29
|
-
</div>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import tailwindcss from "@tailwindcss/vite";
|
|
2
|
-
import { TanStackRouterVite } from "@tanstack/router-plugin/vite";
|
|
3
|
-
import react from "@vitejs/plugin-react";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { defineConfig } from "vite";
|
|
6
|
-
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
plugins: [tailwindcss(), TanStackRouterVite({}), react()],
|
|
9
|
-
resolve: {
|
|
10
|
-
alias: {
|
|
11
|
-
"@": path.resolve(__dirname, "./src"),
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Link } from "@tanstack/react-router";
|
|
2
|
-
|
|
3
|
-
export default function Header() {
|
|
4
|
-
const links = [
|
|
5
|
-
{ to: "/", label: "Home" },
|
|
6
|
-
];
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<div>
|
|
10
|
-
<div className="flex flex-row items-center justify-between px-2 py-1">
|
|
11
|
-
<nav className="flex gap-4 text-lg">
|
|
12
|
-
{links.map(({ to, label }) => (
|
|
13
|
-
<Link
|
|
14
|
-
key={to}
|
|
15
|
-
to={to}
|
|
16
|
-
activeProps={{ className: "font-bold" }}
|
|
17
|
-
activeOptions={{ exact: true }}
|
|
18
|
-
>
|
|
19
|
-
{label}
|
|
20
|
-
</Link>
|
|
21
|
-
))}
|
|
22
|
-
</nav>
|
|
23
|
-
</div>
|
|
24
|
-
<hr />
|
|
25
|
-
</div>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
QueryCache,
|
|
3
|
-
QueryClient,
|
|
4
|
-
QueryClientProvider,
|
|
5
|
-
} from "@tanstack/react-query";
|
|
6
|
-
import { createRouter as createTanstackRouter } from "@tanstack/react-router";
|
|
7
|
-
import { createTRPCClient, httpBatchLink } from "@trpc/client";
|
|
8
|
-
import { createTRPCOptionsProxy } from "@trpc/tanstack-react-query";
|
|
9
|
-
import { toast } from "sonner";
|
|
10
|
-
import type { AppRouter } from "../../server/src/routers";
|
|
11
|
-
import Loader from "./components/loader";
|
|
12
|
-
import "./index.css";
|
|
13
|
-
import { routeTree } from "./routeTree.gen";
|
|
14
|
-
import { TRPCProvider } from "./utils/trpc";
|
|
15
|
-
|
|
16
|
-
export const queryClient = new QueryClient({
|
|
17
|
-
queryCache: new QueryCache({
|
|
18
|
-
onError: (error) => {
|
|
19
|
-
toast.error(error.message, {
|
|
20
|
-
action: {
|
|
21
|
-
label: "retry",
|
|
22
|
-
onClick: () => {
|
|
23
|
-
queryClient.invalidateQueries();
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
},
|
|
28
|
-
}),
|
|
29
|
-
defaultOptions: { queries: { staleTime: 60 * 1000 } },
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const trpcClient = createTRPCClient<AppRouter>({
|
|
33
|
-
links: [
|
|
34
|
-
httpBatchLink({
|
|
35
|
-
url: `${import.meta.env.VITE_SERVER_URL}/trpc`,
|
|
36
|
-
}),
|
|
37
|
-
],
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const trpc = createTRPCOptionsProxy({
|
|
41
|
-
client: trpcClient,
|
|
42
|
-
queryClient: queryClient,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
export const createRouter = () => {
|
|
46
|
-
const router = createTanstackRouter({
|
|
47
|
-
routeTree,
|
|
48
|
-
scrollRestoration: true,
|
|
49
|
-
defaultPreloadStaleTime: 0,
|
|
50
|
-
context: { trpc, queryClient },
|
|
51
|
-
defaultPendingComponent: () => <Loader />,
|
|
52
|
-
defaultNotFoundComponent: () => <div>Not Found</div>,
|
|
53
|
-
Wrap: ({ children }) => (
|
|
54
|
-
<QueryClientProvider client={queryClient}>
|
|
55
|
-
<TRPCProvider trpcClient={trpcClient} queryClient={queryClient}>
|
|
56
|
-
{children}
|
|
57
|
-
</TRPCProvider>
|
|
58
|
-
</QueryClientProvider>
|
|
59
|
-
),
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
return router;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// Register the router instance for type safety
|
|
66
|
-
declare module "@tanstack/react-router" {
|
|
67
|
-
interface Register {
|
|
68
|
-
router: ReturnType<typeof createRouter>;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "better-t-stack",
|
|
3
|
-
"private": true,
|
|
4
|
-
"workspaces": ["apps/*"],
|
|
5
|
-
"scripts": {
|
|
6
|
-
"dev": "turbo dev",
|
|
7
|
-
"build": "turbo build",
|
|
8
|
-
"check-types": "turbo check-types",
|
|
9
|
-
"dev:native": "turbo -F native dev",
|
|
10
|
-
"dev:web": "turbo -F web dev",
|
|
11
|
-
"dev:server": "turbo -F server dev",
|
|
12
|
-
"db:push": "turbo -F server db:push",
|
|
13
|
-
"db:studio": "turbo -F server db:studio"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"turbo": "^2.4.2"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { router, publicProcedure } from "../lib/trpc";
|
|
3
|
-
import { todo } from "../db/schema/todo";
|
|
4
|
-
import { eq } from "drizzle-orm";
|
|
5
|
-
import { db } from "../db";
|
|
6
|
-
|
|
7
|
-
export const todoRouter = router({
|
|
8
|
-
getAll: publicProcedure.query(async () => {
|
|
9
|
-
return await db.select().from(todo);
|
|
10
|
-
}),
|
|
11
|
-
|
|
12
|
-
create: publicProcedure
|
|
13
|
-
.input(z.object({ text: z.string().min(1) }))
|
|
14
|
-
.mutation(async ({ input }) => {
|
|
15
|
-
return await db.insert(todo).values({
|
|
16
|
-
text: input.text,
|
|
17
|
-
});
|
|
18
|
-
}),
|
|
19
|
-
|
|
20
|
-
toggle: publicProcedure
|
|
21
|
-
.input(z.object({ id: z.number(), completed: z.boolean() }))
|
|
22
|
-
.mutation(async ({ input }) => {
|
|
23
|
-
return await db
|
|
24
|
-
.update(todo)
|
|
25
|
-
.set({ completed: input.completed })
|
|
26
|
-
.where(eq(todo.id, input.id));
|
|
27
|
-
}),
|
|
28
|
-
|
|
29
|
-
delete: publicProcedure
|
|
30
|
-
.input(z.object({ id: z.number() }))
|
|
31
|
-
.mutation(async ({ input }) => {
|
|
32
|
-
return await db.delete(todo).where(eq(todo.id, input.id));
|
|
33
|
-
}),
|
|
34
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Context as ElysiaContext } from "elysia";
|
|
2
|
-
import { auth } from "./auth";
|
|
3
|
-
|
|
4
|
-
export type CreateContextOptions = {
|
|
5
|
-
context: ElysiaContext;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export async function createContext({ context }: CreateContextOptions) {
|
|
9
|
-
const session = await auth.api.getSession({
|
|
10
|
-
headers: context.request.headers,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
return {
|
|
14
|
-
session,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type Context = Awaited<ReturnType<typeof createContext>>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { CreateExpressContextOptions } from "@trpc/server/adapters/express";
|
|
2
|
-
import { fromNodeHeaders } from "better-auth/node";
|
|
3
|
-
import { auth } from "./auth";
|
|
4
|
-
|
|
5
|
-
export async function createContext(opts: CreateExpressContextOptions) {
|
|
6
|
-
const session = await auth.api.getSession({
|
|
7
|
-
headers: fromNodeHeaders(opts.req.headers),
|
|
8
|
-
});
|
|
9
|
-
return {
|
|
10
|
-
session,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type Context = Awaited<ReturnType<typeof createContext>>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Context as HonoContext } from "hono";
|
|
2
|
-
import { auth } from "./auth";
|
|
3
|
-
|
|
4
|
-
export type CreateContextOptions = {
|
|
5
|
-
context: HonoContext;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export async function createContext({ context }: CreateContextOptions) {
|
|
9
|
-
const session = await auth.api.getSession({
|
|
10
|
-
headers: context.req.raw.headers,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
return {
|
|
14
|
-
session,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type Context = Awaited<ReturnType<typeof createContext>>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { NextRequest } from "next/server";
|
|
2
|
-
import { auth } from "./auth";
|
|
3
|
-
|
|
4
|
-
export async function createContext(req: NextRequest) {
|
|
5
|
-
const session = await auth.api.getSession({
|
|
6
|
-
headers: req.headers,
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
return {
|
|
10
|
-
session,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type Context = Awaited<ReturnType<typeof createContext>>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { protectedProcedure, publicProcedure, router } from "../lib/trpc";
|
|
2
|
-
import { todoRouter } from "./todo";
|
|
3
|
-
|
|
4
|
-
export const appRouter = router({
|
|
5
|
-
healthCheck: publicProcedure.query(() => {
|
|
6
|
-
return "OK";
|
|
7
|
-
}),
|
|
8
|
-
privateData: protectedProcedure.query(({ ctx }) => {
|
|
9
|
-
return {
|
|
10
|
-
message: "This is private",
|
|
11
|
-
user: ctx.session.user,
|
|
12
|
-
};
|
|
13
|
-
}),
|
|
14
|
-
todo: todoRouter,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export type AppRouter = typeof appRouter;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { betterAuth } from "better-auth";
|
|
2
|
-
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
3
|
-
import { db } from "../db";
|
|
4
|
-
import * as schema from "../db/schema/auth";
|
|
5
|
-
|
|
6
|
-
export const auth = betterAuth({
|
|
7
|
-
database: drizzleAdapter(db, {
|
|
8
|
-
provider: "mysql",
|
|
9
|
-
schema: schema,
|
|
10
|
-
}),
|
|
11
|
-
trustedOrigins: [process.env.CORS_ORIGIN || ""],
|
|
12
|
-
emailAndPassword: {
|
|
13
|
-
enabled: true,
|
|
14
|
-
},
|
|
15
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { betterAuth } from "better-auth";
|
|
2
|
-
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
3
|
-
import { db } from "../db";
|
|
4
|
-
import * as schema from "../db/schema/auth";
|
|
5
|
-
|
|
6
|
-
export const auth = betterAuth({
|
|
7
|
-
database: drizzleAdapter(db, {
|
|
8
|
-
provider: "pg",
|
|
9
|
-
schema: schema,
|
|
10
|
-
}),
|
|
11
|
-
trustedOrigins: [process.env.CORS_ORIGIN || ""],
|
|
12
|
-
emailAndPassword: {
|
|
13
|
-
enabled: true,
|
|
14
|
-
},
|
|
15
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { betterAuth } from "better-auth";
|
|
2
|
-
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
3
|
-
import { db } from "../db";
|
|
4
|
-
import * as schema from "../db/schema/auth";
|
|
5
|
-
|
|
6
|
-
export const auth = betterAuth({
|
|
7
|
-
database: drizzleAdapter(db, {
|
|
8
|
-
provider: "sqlite",
|
|
9
|
-
schema: schema,
|
|
10
|
-
}),
|
|
11
|
-
trustedOrigins: [process.env.CORS_ORIGIN || ""],
|
|
12
|
-
emailAndPassword: {
|
|
13
|
-
enabled: true,
|
|
14
|
-
},
|
|
15
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
import { createExpressMiddleware } from "@trpc/server/adapters/express";
|
|
3
|
-
import { toNodeHandler } from "better-auth/node";
|
|
4
|
-
import cors from "cors";
|
|
5
|
-
import express from "express";
|
|
6
|
-
import { auth } from "./lib/auth";
|
|
7
|
-
import { createContext } from "./lib/context";
|
|
8
|
-
import { appRouter } from "./routers/index";
|
|
9
|
-
|
|
10
|
-
const app = express();
|
|
11
|
-
|
|
12
|
-
app.use(
|
|
13
|
-
cors({
|
|
14
|
-
origin: process.env.CORS_ORIGIN || "",
|
|
15
|
-
methods: ["GET", "POST", "OPTIONS"],
|
|
16
|
-
allowedHeaders: ["Content-Type", "Authorization"],
|
|
17
|
-
credentials: true,
|
|
18
|
-
}),
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
app.all("/api/auth{/*path}", toNodeHandler(auth));
|
|
22
|
-
app.use(express.json());
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
app.use("/trpc", createExpressMiddleware({ router: appRouter, createContext }));
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
app.get("/", (_req, res) => {
|
|
29
|
-
res.status(200).send("OK");
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
app.listen(3000, () => {
|
|
33
|
-
console.log("Server is running on port 3000");
|
|
34
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { trpcServer } from "@hono/trpc-server";
|
|
3
|
-
import "dotenv/config";
|
|
4
|
-
import { Hono } from "hono";
|
|
5
|
-
import { cors } from "hono/cors";
|
|
6
|
-
import { logger } from "hono/logger";
|
|
7
|
-
import { auth } from "./lib/auth";
|
|
8
|
-
import { createContext } from "./lib/context";
|
|
9
|
-
import { appRouter } from "./routers/index";
|
|
10
|
-
|
|
11
|
-
const app = new Hono();
|
|
12
|
-
|
|
13
|
-
app.use(logger());
|
|
14
|
-
|
|
15
|
-
app.use(
|
|
16
|
-
"/*",
|
|
17
|
-
cors({
|
|
18
|
-
origin: process.env.CORS_ORIGIN || "",
|
|
19
|
-
allowMethods: ["GET", "POST", "OPTIONS"],
|
|
20
|
-
allowHeaders: ["Content-Type", "Authorization"],
|
|
21
|
-
credentials: true,
|
|
22
|
-
}),
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
app.on(["POST", "GET"], "/api/auth/**", (c) => auth.handler(c.req.raw));
|
|
26
|
-
|
|
27
|
-
app.use(
|
|
28
|
-
"/trpc/*",
|
|
29
|
-
trpcServer({
|
|
30
|
-
router: appRouter,
|
|
31
|
-
createContext: (_opts, context) => {
|
|
32
|
-
return createContext({ context });
|
|
33
|
-
},
|
|
34
|
-
}),
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
app.get("/", (c) => {
|
|
38
|
-
return c.text("OK");
|
|
39
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { betterAuth } from "better-auth";
|
|
2
|
-
import { prismaAdapter } from "better-auth/adapters/prisma";
|
|
3
|
-
import prisma from "../../prisma";
|
|
4
|
-
|
|
5
|
-
export const auth = betterAuth({
|
|
6
|
-
database: prismaAdapter(prisma, {
|
|
7
|
-
provider: "mongodb",
|
|
8
|
-
}),
|
|
9
|
-
trustedOrigins: [process.env.CORS_ORIGIN || ""],
|
|
10
|
-
emailAndPassword: { enabled: true },
|
|
11
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { betterAuth } from "better-auth";
|
|
2
|
-
import { prismaAdapter } from "better-auth/adapters/prisma";
|
|
3
|
-
import prisma from "../../prisma";
|
|
4
|
-
|
|
5
|
-
export const auth = betterAuth({
|
|
6
|
-
database: prismaAdapter(prisma, {
|
|
7
|
-
provider: "mysql",
|
|
8
|
-
}),
|
|
9
|
-
trustedOrigins: [process.env.CORS_ORIGIN || ""],
|
|
10
|
-
emailAndPassword: { enabled: true },
|
|
11
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { betterAuth } from "better-auth";
|
|
2
|
-
import { prismaAdapter } from "better-auth/adapters/prisma";
|
|
3
|
-
import prisma from "../../prisma";
|
|
4
|
-
|
|
5
|
-
export const auth = betterAuth({
|
|
6
|
-
database: prismaAdapter(prisma, {
|
|
7
|
-
provider: "postgresql",
|
|
8
|
-
}),
|
|
9
|
-
trustedOrigins: [process.env.CORS_ORIGIN || ""],
|
|
10
|
-
emailAndPassword: { enabled: true },
|
|
11
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { betterAuth } from "better-auth";
|
|
2
|
-
import { prismaAdapter } from "better-auth/adapters/prisma";
|
|
3
|
-
import prisma from "../../prisma";
|
|
4
|
-
|
|
5
|
-
export const auth = betterAuth({
|
|
6
|
-
database: prismaAdapter(prisma, {
|
|
7
|
-
provider: "sqlite",
|
|
8
|
-
}),
|
|
9
|
-
trustedOrigins: [process.env.CORS_ORIGIN || ""],
|
|
10
|
-
emailAndPassword: { enabled: true },
|
|
11
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
import Link from "next/link";
|
|
3
|
-
import { ModeToggle } from "./mode-toggle";
|
|
4
|
-
import UserMenu from "./user-menu";
|
|
5
|
-
|
|
6
|
-
export default function Header() {
|
|
7
|
-
const links = [
|
|
8
|
-
{ to: "/", label: "Home" },
|
|
9
|
-
{ to: "/dashboard", label: "Dashboard" },
|
|
10
|
-
];
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<div>
|
|
14
|
-
<div className="flex flex-row items-center justify-between px-2 py-1">
|
|
15
|
-
<nav className="flex gap-4 text-lg">
|
|
16
|
-
{links.map(({ to, label }) => (
|
|
17
|
-
<Link
|
|
18
|
-
key={to}
|
|
19
|
-
href={to}
|
|
20
|
-
>
|
|
21
|
-
{label}
|
|
22
|
-
</Link>
|
|
23
|
-
))}
|
|
24
|
-
</nav>
|
|
25
|
-
<div className="flex items-center gap-2">
|
|
26
|
-
<ModeToggle />
|
|
27
|
-
<UserMenu />
|
|
28
|
-
</div>
|
|
29
|
-
</div>
|
|
30
|
-
<hr />
|
|
31
|
-
</div>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { QueryCache, QueryClient } from '@tanstack/react-query';
|
|
2
|
-
import { createTRPCClient, httpBatchLink } from '@trpc/client';
|
|
3
|
-
import { createTRPCOptionsProxy } from '@trpc/tanstack-react-query';
|
|
4
|
-
import type { AppRouter } from '../../../server/src/routers';
|
|
5
|
-
import { toast } from 'sonner';
|
|
6
|
-
|
|
7
|
-
export const queryClient = new QueryClient({
|
|
8
|
-
queryCache: new QueryCache({
|
|
9
|
-
onError: (error) => {
|
|
10
|
-
toast.error(error.message, {
|
|
11
|
-
action: {
|
|
12
|
-
label: "retry",
|
|
13
|
-
onClick: () => {
|
|
14
|
-
queryClient.invalidateQueries();
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
}),
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const trpcClient = createTRPCClient<AppRouter>({
|
|
23
|
-
links: [
|
|
24
|
-
httpBatchLink({
|
|
25
|
-
url: `${process.env.NEXT_PUBLIC_SERVER_URL}/trpc`,
|
|
26
|
-
fetch(url, options) {
|
|
27
|
-
return fetch(url, {
|
|
28
|
-
...options,
|
|
29
|
-
credentials: "include",
|
|
30
|
-
});
|
|
31
|
-
},
|
|
32
|
-
}),
|
|
33
|
-
],
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
export const trpc = createTRPCOptionsProxy<AppRouter>({
|
|
37
|
-
client: trpcClient,
|
|
38
|
-
queryClient,
|
|
39
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { NavLink } from "react-router";
|
|
2
|
-
import { ModeToggle } from "./mode-toggle";
|
|
3
|
-
import UserMenu from "./user-menu";
|
|
4
|
-
|
|
5
|
-
export default function Header() {
|
|
6
|
-
const links = [
|
|
7
|
-
{ to: "/", label: "Home" },
|
|
8
|
-
{ to: "/dashboard", label: "Dashboard" },
|
|
9
|
-
];
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<div>
|
|
13
|
-
<div className="flex flex-row items-center justify-between px-2 py-1">
|
|
14
|
-
<nav className="flex gap-4 text-lg">
|
|
15
|
-
{links.map(({ to, label }) => (
|
|
16
|
-
<NavLink
|
|
17
|
-
key={to}
|
|
18
|
-
to={to}
|
|
19
|
-
className={({ isActive }) => (isActive ? "font-bold" : "")}
|
|
20
|
-
end
|
|
21
|
-
>
|
|
22
|
-
{label}
|
|
23
|
-
</NavLink>
|
|
24
|
-
))}
|
|
25
|
-
</nav>
|
|
26
|
-
<div className="flex items-center gap-2">
|
|
27
|
-
<ModeToggle />
|
|
28
|
-
<UserMenu />
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
|
-
<hr />
|
|
32
|
-
</div>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { AppRouter } from "../../../server/src/routers";
|
|
2
|
-
import { QueryCache, QueryClient } from "@tanstack/react-query";
|
|
3
|
-
import { createTRPCClient, httpBatchLink } from "@trpc/client";
|
|
4
|
-
import { createTRPCOptionsProxy } from "@trpc/tanstack-react-query";
|
|
5
|
-
import { toast } from "sonner";
|
|
6
|
-
|
|
7
|
-
export const queryClient = new QueryClient({
|
|
8
|
-
queryCache: new QueryCache({
|
|
9
|
-
onError: (error) => {
|
|
10
|
-
toast.error(error.message, {
|
|
11
|
-
action: {
|
|
12
|
-
label: "retry",
|
|
13
|
-
onClick: () => {
|
|
14
|
-
queryClient.invalidateQueries();
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
}),
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
export const trpcClient = createTRPCClient<AppRouter>({
|
|
23
|
-
links: [
|
|
24
|
-
httpBatchLink({
|
|
25
|
-
url: `${import.meta.env.VITE_SERVER_URL}/trpc`,
|
|
26
|
-
fetch(url, options) {
|
|
27
|
-
return fetch(url, {
|
|
28
|
-
...options,
|
|
29
|
-
credentials: "include",
|
|
30
|
-
});
|
|
31
|
-
},
|
|
32
|
-
}),
|
|
33
|
-
],
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
export const trpc = createTRPCOptionsProxy<AppRouter>({
|
|
37
|
-
client: trpcClient,
|
|
38
|
-
queryClient,
|
|
39
|
-
});
|