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,5 +1,10 @@
|
|
|
1
1
|
import { authClient } from "@/lib/auth-client";
|
|
2
|
+
{{#if (eq api "trpc")}}
|
|
2
3
|
import { useTRPC } from "@/utils/trpc";
|
|
4
|
+
{{/if}}
|
|
5
|
+
{{#if (eq api "orpc")}}
|
|
6
|
+
import { useORPC } from "@/utils/orpc";
|
|
7
|
+
{{/if}}
|
|
3
8
|
import { useQuery } from "@tanstack/react-query";
|
|
4
9
|
import { createFileRoute } from "@tanstack/react-router";
|
|
5
10
|
import { useEffect } from "react";
|
|
@@ -10,10 +15,20 @@ export const Route = createFileRoute("/dashboard")({
|
|
|
10
15
|
|
|
11
16
|
function RouteComponent() {
|
|
12
17
|
const navigate = Route.useNavigate();
|
|
18
|
+
{{#if (eq api "trpc")}}
|
|
13
19
|
const trpc = useTRPC();
|
|
20
|
+
{{/if}}
|
|
21
|
+
{{#if (eq api "orpc")}}
|
|
22
|
+
const orpc = useORPC();
|
|
23
|
+
{{/if}}
|
|
14
24
|
const { data: session, isPending } = authClient.useSession();
|
|
15
25
|
|
|
26
|
+
{{#if (eq api "trpc")}}
|
|
16
27
|
const privateData = useQuery(trpc.privateData.queryOptions());
|
|
28
|
+
{{/if}}
|
|
29
|
+
{{#if (eq api "orpc")}}
|
|
30
|
+
const privateData = useQuery(orpc.privateData.queryOptions());
|
|
31
|
+
{{/if}}
|
|
17
32
|
|
|
18
33
|
useEffect(() => {
|
|
19
34
|
if (!session && !isPending) {
|
|
@@ -1,20 +1,43 @@
|
|
|
1
|
+
{{#if (eq runtime "node")}}
|
|
2
|
+
import { node } from "@elysiajs/node";
|
|
3
|
+
{{/if}}
|
|
1
4
|
import "dotenv/config";
|
|
2
5
|
import { Elysia } from "elysia";
|
|
3
6
|
import { cors } from "@elysiajs/cors";
|
|
4
|
-
|
|
7
|
+
{{#if (eq api "trpc")}}
|
|
5
8
|
import { createContext } from "./lib/context";
|
|
6
9
|
import { appRouter } from "./routers/index";
|
|
7
10
|
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
|
|
11
|
+
{{/if}}
|
|
12
|
+
{{#if (eq api "orpc")}}
|
|
13
|
+
import { RPCHandler } from "@orpc/server/fetch";
|
|
14
|
+
import { appRouter } from "./routers";
|
|
15
|
+
import { createContext } from "./lib/context";
|
|
16
|
+
{{/if}}
|
|
17
|
+
{{#if auth}}
|
|
18
|
+
import { auth } from "./lib/auth";
|
|
19
|
+
{{/if}}
|
|
8
20
|
|
|
21
|
+
{{#if (eq api "orpc")}}
|
|
22
|
+
const handler = new RPCHandler(appRouter);
|
|
23
|
+
{{/if}}
|
|
24
|
+
|
|
25
|
+
{{#if (eq runtime "node")}}
|
|
26
|
+
const app = new Elysia({ adapter: node() })
|
|
27
|
+
{{else}}
|
|
9
28
|
const app = new Elysia()
|
|
29
|
+
{{/if}}
|
|
10
30
|
.use(
|
|
11
31
|
cors({
|
|
12
32
|
origin: process.env.CORS_ORIGIN || "",
|
|
13
33
|
methods: ["GET", "POST", "OPTIONS"],
|
|
34
|
+
{{#if auth}}
|
|
14
35
|
allowedHeaders: ["Content-Type", "Authorization"],
|
|
15
36
|
credentials: true,
|
|
37
|
+
{{/if}}
|
|
16
38
|
}),
|
|
17
39
|
)
|
|
40
|
+
{{#if auth}}
|
|
18
41
|
.all("/api/auth/*", async (context) => {
|
|
19
42
|
const { request } = context;
|
|
20
43
|
if (["POST", "GET"].includes(request.method)) {
|
|
@@ -22,6 +45,17 @@ const app = new Elysia()
|
|
|
22
45
|
}
|
|
23
46
|
context.error(405);
|
|
24
47
|
})
|
|
48
|
+
{{/if}}
|
|
49
|
+
{{#if (eq api "orpc")}}
|
|
50
|
+
.all('/rpc*', async (context) => {
|
|
51
|
+
const { response } = await handler.handle(context.request, {
|
|
52
|
+
prefix: '/rpc',
|
|
53
|
+
context: await createContext({ context })
|
|
54
|
+
})
|
|
55
|
+
return response ?? new Response('Not Found', { status: 404 })
|
|
56
|
+
})
|
|
57
|
+
{{/if}}
|
|
58
|
+
{{#if (eq api "trpc")}}
|
|
25
59
|
.all("/trpc/*", async (context) => {
|
|
26
60
|
const res = await fetchRequestHandler({
|
|
27
61
|
endpoint: "/trpc",
|
|
@@ -31,7 +65,8 @@ const app = new Elysia()
|
|
|
31
65
|
});
|
|
32
66
|
return res;
|
|
33
67
|
})
|
|
68
|
+
{{/if}}
|
|
34
69
|
.get("/", () => "OK")
|
|
35
70
|
.listen(3000, () => {
|
|
36
|
-
console.log(
|
|
37
|
-
});
|
|
71
|
+
console.log(`Server is running on http://localhost:3000`);
|
|
72
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import "dotenv/config";
|
|
2
|
+
{{#if (eq api "trpc")}}
|
|
3
|
+
import { createExpressMiddleware } from "@trpc/server/adapters/express";
|
|
4
|
+
import { createContext } from "./lib/context";
|
|
5
|
+
import { appRouter } from "./routers/index";
|
|
6
|
+
{{/if}}
|
|
7
|
+
{{#if (eq api "orpc")}}
|
|
8
|
+
import { RPCHandler } from "@orpc/server/node";
|
|
9
|
+
import { appRouter } from "./routers";
|
|
10
|
+
{{/if}}
|
|
11
|
+
import cors from "cors";
|
|
12
|
+
import express from "express";
|
|
13
|
+
{{#if (includes examples "ai")}}
|
|
14
|
+
import { streamText } from "ai";
|
|
15
|
+
import { google } from "@ai-sdk/google";
|
|
16
|
+
{{/if}}
|
|
17
|
+
{{#if auth}}
|
|
18
|
+
import { auth } from "./lib/auth";
|
|
19
|
+
{{/if}}
|
|
20
|
+
|
|
21
|
+
const app = express();
|
|
22
|
+
|
|
23
|
+
app.use(
|
|
24
|
+
cors({
|
|
25
|
+
origin: process.env.CORS_ORIGIN || "",
|
|
26
|
+
methods: ["GET", "POST", "OPTIONS"],
|
|
27
|
+
{{#if auth}}
|
|
28
|
+
allowedHeaders: ["Content-Type", "Authorization"],
|
|
29
|
+
credentials: true,
|
|
30
|
+
{{/if}}
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
{{#if auth}}
|
|
35
|
+
app.all("/api/auth{/*path}", toNodeHandler(auth));
|
|
36
|
+
{{/if}}
|
|
37
|
+
|
|
38
|
+
{{#if (eq api "trpc")}}
|
|
39
|
+
app.use(
|
|
40
|
+
"/trpc",
|
|
41
|
+
createExpressMiddleware({
|
|
42
|
+
router: appRouter,
|
|
43
|
+
createContext
|
|
44
|
+
})
|
|
45
|
+
);
|
|
46
|
+
{{/if}}
|
|
47
|
+
|
|
48
|
+
{{#if (eq api "orpc")}}
|
|
49
|
+
const handler = new RPCHandler(appRouter);
|
|
50
|
+
app.use('/rpc{*path}', async (req, res, next) => {
|
|
51
|
+
const { matched } = await handler.handle(req, res, {
|
|
52
|
+
prefix: '/rpc',
|
|
53
|
+
context: {},
|
|
54
|
+
});
|
|
55
|
+
if (matched) return;
|
|
56
|
+
next();
|
|
57
|
+
});
|
|
58
|
+
{{/if}}
|
|
59
|
+
|
|
60
|
+
{{#if (includes examples "ai")}}
|
|
61
|
+
// AI chat endpoint
|
|
62
|
+
app.post("/ai", async (req, res) => {
|
|
63
|
+
const { messages = [] } = req.body;
|
|
64
|
+
const result = streamText({
|
|
65
|
+
model: google("gemini-1.5-flash"),
|
|
66
|
+
messages,
|
|
67
|
+
});
|
|
68
|
+
result.pipeDataStreamToResponse(res);
|
|
69
|
+
});
|
|
70
|
+
{{/if}}
|
|
71
|
+
|
|
72
|
+
app.get("/", (_req, res) => {
|
|
73
|
+
res.status(200).send("OK");
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
app.listen(3000, () => {
|
|
77
|
+
console.log("Server is running on port 3000");
|
|
78
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{{#if (eq api "orpc")}}
|
|
2
|
+
import { RPCHandler } from "@orpc/server/fetch";
|
|
3
|
+
import { createContext } from "./lib/context";
|
|
4
|
+
import { appRouter } from "./routers/index";
|
|
5
|
+
{{#if auth}}
|
|
6
|
+
import { auth } from "./lib/auth";
|
|
7
|
+
{{/if}}
|
|
8
|
+
{{/if}}
|
|
9
|
+
{{#if (eq api "trpc")}}
|
|
10
|
+
import { trpcServer } from "@hono/trpc-server";
|
|
11
|
+
{{/if}}
|
|
12
|
+
import "dotenv/config";
|
|
13
|
+
import { Hono } from "hono";
|
|
14
|
+
import { cors } from "hono/cors";
|
|
15
|
+
import { logger } from "hono/logger";
|
|
16
|
+
{{#if (includes examples "ai")}}
|
|
17
|
+
import { streamText } from "ai";
|
|
18
|
+
import { google } from "@ai-sdk/google";
|
|
19
|
+
import { stream } from "hono/streaming";
|
|
20
|
+
{{/if}}
|
|
21
|
+
{{#if (eq api "trpc")}}
|
|
22
|
+
import { createContext } from "./lib/context";
|
|
23
|
+
import { appRouter } from "./routers/index";
|
|
24
|
+
{{#if auth}}
|
|
25
|
+
import { auth } from "./lib/auth";
|
|
26
|
+
{{/if}}
|
|
27
|
+
{{/if}}
|
|
28
|
+
|
|
29
|
+
const app = new Hono();
|
|
30
|
+
|
|
31
|
+
app.use(logger());
|
|
32
|
+
app.use(
|
|
33
|
+
"/*",
|
|
34
|
+
cors({
|
|
35
|
+
origin: process.env.CORS_ORIGIN || "",
|
|
36
|
+
allowMethods: ["GET", "POST", "OPTIONS"],
|
|
37
|
+
{{#if auth}}
|
|
38
|
+
allowHeaders: ["Content-Type", "Authorization"],
|
|
39
|
+
credentials: true,
|
|
40
|
+
{{/if}}
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
{{#if auth}}
|
|
45
|
+
app.on(["POST", "GET"], "/api/auth/**", (c) => auth.handler(c.req.raw));
|
|
46
|
+
{{/if}}
|
|
47
|
+
|
|
48
|
+
{{#if (eq api "orpc")}}
|
|
49
|
+
const handler = new RPCHandler(appRouter);
|
|
50
|
+
app.use("/rpc/*", async (c, next) => {
|
|
51
|
+
const context = await createContext({ context: c });
|
|
52
|
+
const { matched, response } = await handler.handle(c.req.raw, {
|
|
53
|
+
prefix: "/rpc",
|
|
54
|
+
context: context,
|
|
55
|
+
});
|
|
56
|
+
if (matched) {
|
|
57
|
+
return c.newResponse(response.body, response);
|
|
58
|
+
}
|
|
59
|
+
await next();
|
|
60
|
+
});
|
|
61
|
+
{{/if}}
|
|
62
|
+
|
|
63
|
+
{{#if (eq api "trpc")}}
|
|
64
|
+
app.use("/trpc/*", trpcServer({
|
|
65
|
+
router: appRouter,
|
|
66
|
+
createContext: (_opts, context) => {
|
|
67
|
+
return createContext({ context });
|
|
68
|
+
},
|
|
69
|
+
}));
|
|
70
|
+
{{/if}}
|
|
71
|
+
|
|
72
|
+
{{#if (includes examples "ai")}}
|
|
73
|
+
// AI chat endpoint
|
|
74
|
+
app.post("/ai", async (c) => {
|
|
75
|
+
const body = await c.req.json();
|
|
76
|
+
const messages = body.messages || [];
|
|
77
|
+
|
|
78
|
+
const result = streamText({
|
|
79
|
+
model: google("gemini-1.5-flash"),
|
|
80
|
+
messages,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
c.header("X-Vercel-AI-Data-Stream", "v1");
|
|
84
|
+
c.header("Content-Type", "text/plain; charset=utf-8");
|
|
85
|
+
|
|
86
|
+
return stream(c, (stream) => stream.pipe(result.toDataStream()));
|
|
87
|
+
});
|
|
88
|
+
{{/if}}
|
|
89
|
+
|
|
90
|
+
app.get("/", (c) => {
|
|
91
|
+
return c.text("OK");
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
{{#if (eq runtime "node")}}
|
|
95
|
+
import { serve } from "@hono/node-server";
|
|
96
|
+
|
|
97
|
+
serve({
|
|
98
|
+
fetch: app.fetch,
|
|
99
|
+
port: 3000,
|
|
100
|
+
}, (info) => {
|
|
101
|
+
console.log(`Server is running on http://localhost:${info.port}`);
|
|
102
|
+
});
|
|
103
|
+
{{else}}
|
|
104
|
+
export default app;
|
|
105
|
+
{{/if}}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{{#if (eq api "orpc")}}
|
|
2
|
+
import { {{#if auth}}protectedProcedure, {{/if}}publicProcedure } from "../lib/orpc";
|
|
3
|
+
{{#if (includes examples "todo")}}
|
|
4
|
+
import { todoRouter } from "./todo";
|
|
5
|
+
{{/if}}
|
|
6
|
+
|
|
7
|
+
export const appRouter = {
|
|
8
|
+
healthCheck: publicProcedure.handler(() => {
|
|
9
|
+
return "OK";
|
|
10
|
+
}),
|
|
11
|
+
{{#if auth}}
|
|
12
|
+
privateData: protectedProcedure.handler(({ context }) => {
|
|
13
|
+
return {
|
|
14
|
+
message: "This is private",
|
|
15
|
+
user: context.session!.user,
|
|
16
|
+
};
|
|
17
|
+
}),
|
|
18
|
+
{{/if}}
|
|
19
|
+
{{#if (includes examples "todo")}}
|
|
20
|
+
todo: todoRouter,
|
|
21
|
+
{{/if}}
|
|
22
|
+
};
|
|
23
|
+
{{/if}}
|
|
24
|
+
|
|
25
|
+
{{#if (eq api "trpc")}}
|
|
26
|
+
import {
|
|
27
|
+
{{#if auth}}protectedProcedure, {{/if}}publicProcedure,
|
|
28
|
+
router,
|
|
29
|
+
} from "../lib/trpc";
|
|
30
|
+
{{#if (includes examples "todo")}}
|
|
31
|
+
import { todoRouter } from "./todo";
|
|
32
|
+
{{/if}}
|
|
33
|
+
|
|
34
|
+
export const appRouter = router({
|
|
35
|
+
healthCheck: publicProcedure.query(() => {
|
|
36
|
+
return "OK";
|
|
37
|
+
}),
|
|
38
|
+
{{#if auth}}
|
|
39
|
+
privateData: protectedProcedure.query(({ ctx }) => {
|
|
40
|
+
return {
|
|
41
|
+
message: "This is private",
|
|
42
|
+
user: ctx.session.user,
|
|
43
|
+
};
|
|
44
|
+
}),
|
|
45
|
+
{{/if}}
|
|
46
|
+
{{#if (includes examples "todo")}}
|
|
47
|
+
todo: todoRouter,
|
|
48
|
+
{{/if}}
|
|
49
|
+
});
|
|
50
|
+
{{/if}}
|
|
51
|
+
export type AppRouter = typeof appRouter;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{{#if (eq api "orpc")}}
|
|
2
|
+
import { eq } from "drizzle-orm";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { db } from "../db";
|
|
5
|
+
import { todo } from "../db/schema/todo";
|
|
6
|
+
import { publicProcedure } from "../lib/orpc";
|
|
7
|
+
|
|
8
|
+
export const todoRouter = {
|
|
9
|
+
getAll: publicProcedure.handler(async () => {
|
|
10
|
+
return await db.select().from(todo);
|
|
11
|
+
}),
|
|
12
|
+
|
|
13
|
+
create: publicProcedure
|
|
14
|
+
.input(z.object({ text: z.string().min(1) }))
|
|
15
|
+
.handler(async ({ input }) => {
|
|
16
|
+
const result = await db
|
|
17
|
+
.insert(todo)
|
|
18
|
+
.values({
|
|
19
|
+
text: input.text,
|
|
20
|
+
})
|
|
21
|
+
.returning();
|
|
22
|
+
return result[0];
|
|
23
|
+
}),
|
|
24
|
+
|
|
25
|
+
toggle: publicProcedure
|
|
26
|
+
.input(z.object({ id: z.number(), completed: z.boolean() }))
|
|
27
|
+
.handler(async ({ input }) => {
|
|
28
|
+
await db
|
|
29
|
+
.update(todo)
|
|
30
|
+
.set({ completed: input.completed })
|
|
31
|
+
.where(eq(todo.id, input.id));
|
|
32
|
+
return { success: true };
|
|
33
|
+
}),
|
|
34
|
+
|
|
35
|
+
delete: publicProcedure
|
|
36
|
+
.input(z.object({ id: z.number() }))
|
|
37
|
+
.handler(async ({ input }) => {
|
|
38
|
+
await db.delete(todo).where(eq(todo.id, input.id));
|
|
39
|
+
return { success: true };
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
{{/if}}
|
|
43
|
+
|
|
44
|
+
{{#if (eq api "trpc")}}
|
|
45
|
+
import { z } from "zod";
|
|
46
|
+
import { router, publicProcedure } from "../lib/trpc";
|
|
47
|
+
import { todo } from "../db/schema/todo";
|
|
48
|
+
import { eq } from "drizzle-orm";
|
|
49
|
+
import { db } from "../db";
|
|
50
|
+
|
|
51
|
+
export const todoRouter = router({
|
|
52
|
+
getAll: publicProcedure.query(async () => {
|
|
53
|
+
return await db.select().from(todo);
|
|
54
|
+
}),
|
|
55
|
+
|
|
56
|
+
create: publicProcedure
|
|
57
|
+
.input(z.object({ text: z.string().min(1) }))
|
|
58
|
+
.mutation(async ({ input }) => {
|
|
59
|
+
return await db.insert(todo).values({
|
|
60
|
+
text: input.text,
|
|
61
|
+
});
|
|
62
|
+
}),
|
|
63
|
+
|
|
64
|
+
toggle: publicProcedure
|
|
65
|
+
.input(z.object({ id: z.number(), completed: z.boolean() }))
|
|
66
|
+
.mutation(async ({ input }) => {
|
|
67
|
+
return await db
|
|
68
|
+
.update(todo)
|
|
69
|
+
.set({ completed: input.completed })
|
|
70
|
+
.where(eq(todo.id, input.id));
|
|
71
|
+
}),
|
|
72
|
+
|
|
73
|
+
delete: publicProcedure
|
|
74
|
+
.input(z.object({ id: z.number() }))
|
|
75
|
+
.mutation(async ({ input }) => {
|
|
76
|
+
return await db.delete(todo).where(eq(todo.id, input.id));
|
|
77
|
+
}),
|
|
78
|
+
});
|
|
79
|
+
{{/if}}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { sqliteTable, text
|
|
1
|
+
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
|
|
2
2
|
|
|
3
3
|
export const todo = sqliteTable("todo", {
|
|
4
4
|
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
5
5
|
text: text("text").notNull(),
|
|
6
|
-
completed: integer("completed", { mode: "boolean" }).default(false).notNull()
|
|
6
|
+
completed: integer("completed", { mode: "boolean" }).default(false).notNull(),
|
|
7
7
|
});
|
|
@@ -8,7 +8,12 @@ import {
|
|
|
8
8
|
} from "@/components/ui/card";
|
|
9
9
|
import { Checkbox } from "@/components/ui/checkbox";
|
|
10
10
|
import { Input } from "@/components/ui/input";
|
|
11
|
+
{{#if (eq api "orpc")}}
|
|
12
|
+
import { orpc } from "@/utils/orpc";
|
|
13
|
+
{{/if}}
|
|
14
|
+
{{#if (eq api "trpc")}}
|
|
11
15
|
import { trpc } from "@/utils/trpc";
|
|
16
|
+
{{/if}}
|
|
12
17
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
13
18
|
import { Loader2, Trash2 } from "lucide-react";
|
|
14
19
|
import { useState } from "react";
|
|
@@ -16,6 +21,28 @@ import { useState } from "react";
|
|
|
16
21
|
export default function Todos() {
|
|
17
22
|
const [newTodoText, setNewTodoText] = useState("");
|
|
18
23
|
|
|
24
|
+
{{#if (eq api "orpc")}}
|
|
25
|
+
const todos = useQuery(orpc.todo.getAll.queryOptions());
|
|
26
|
+
const createMutation = useMutation(
|
|
27
|
+
orpc.todo.create.mutationOptions({
|
|
28
|
+
onSuccess: () => {
|
|
29
|
+
todos.refetch();
|
|
30
|
+
setNewTodoText("");
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
const toggleMutation = useMutation(
|
|
35
|
+
orpc.todo.toggle.mutationOptions({
|
|
36
|
+
onSuccess: () => todos.refetch(),
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
const deleteMutation = useMutation(
|
|
40
|
+
orpc.todo.delete.mutationOptions({
|
|
41
|
+
onSuccess: () => todos.refetch(),
|
|
42
|
+
})
|
|
43
|
+
);
|
|
44
|
+
{{/if}}
|
|
45
|
+
{{#if (eq api "trpc")}}
|
|
19
46
|
const todos = useQuery(trpc.todo.getAll.queryOptions());
|
|
20
47
|
const createMutation = useMutation(
|
|
21
48
|
trpc.todo.create.mutationOptions({
|
|
@@ -35,6 +62,7 @@ export default function Todos() {
|
|
|
35
62
|
onSuccess: () => todos.refetch(),
|
|
36
63
|
})
|
|
37
64
|
);
|
|
65
|
+
{{/if}}
|
|
38
66
|
|
|
39
67
|
const handleAddTodo = (e: React.FormEvent) => {
|
|
40
68
|
e.preventDefault();
|
|
@@ -8,7 +8,12 @@ import {
|
|
|
8
8
|
} from "@/components/ui/card";
|
|
9
9
|
import { Checkbox } from "@/components/ui/checkbox";
|
|
10
10
|
import { Input } from "@/components/ui/input";
|
|
11
|
+
{{#if (eq api "orpc")}}
|
|
12
|
+
import { orpc } from "@/utils/orpc";
|
|
13
|
+
{{/if}}
|
|
14
|
+
{{#if (eq api "trpc")}}
|
|
11
15
|
import { trpc } from "@/utils/trpc";
|
|
16
|
+
{{/if}}
|
|
12
17
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
13
18
|
import { createFileRoute } from "@tanstack/react-router";
|
|
14
19
|
import { Loader2, Trash2 } from "lucide-react";
|
|
@@ -21,6 +26,28 @@ export const Route = createFileRoute("/todos")({
|
|
|
21
26
|
function TodosRoute() {
|
|
22
27
|
const [newTodoText, setNewTodoText] = useState("");
|
|
23
28
|
|
|
29
|
+
{{#if (eq api "orpc")}}
|
|
30
|
+
const todos = useQuery(orpc.todo.getAll.queryOptions());
|
|
31
|
+
const createMutation = useMutation(
|
|
32
|
+
orpc.todo.create.mutationOptions({
|
|
33
|
+
onSuccess: () => {
|
|
34
|
+
todos.refetch();
|
|
35
|
+
setNewTodoText("");
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
);
|
|
39
|
+
const toggleMutation = useMutation(
|
|
40
|
+
orpc.todo.toggle.mutationOptions({
|
|
41
|
+
onSuccess: () => todos.refetch(),
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
44
|
+
const deleteMutation = useMutation(
|
|
45
|
+
orpc.todo.delete.mutationOptions({
|
|
46
|
+
onSuccess: () => todos.refetch(),
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
49
|
+
{{/if}}
|
|
50
|
+
{{#if (eq api "trpc")}}
|
|
24
51
|
const todos = useQuery(trpc.todo.getAll.queryOptions());
|
|
25
52
|
const createMutation = useMutation(
|
|
26
53
|
trpc.todo.create.mutationOptions({
|
|
@@ -40,6 +67,7 @@ function TodosRoute() {
|
|
|
40
67
|
onSuccess: () => todos.refetch(),
|
|
41
68
|
}),
|
|
42
69
|
);
|
|
70
|
+
{{/if}}
|
|
43
71
|
|
|
44
72
|
const handleAddTodo = (e: React.FormEvent) => {
|
|
45
73
|
e.preventDefault();
|
|
@@ -8,7 +8,12 @@ import {
|
|
|
8
8
|
} from "@/components/ui/card";
|
|
9
9
|
import { Checkbox } from "@/components/ui/checkbox";
|
|
10
10
|
import { Input } from "@/components/ui/input";
|
|
11
|
+
{{#if (eq api "trpc")}}
|
|
11
12
|
import { useTRPC } from "@/utils/trpc";
|
|
13
|
+
{{/if}}
|
|
14
|
+
{{#if (eq api "orpc")}}
|
|
15
|
+
import { useORPC } from "@/utils/orpc";
|
|
16
|
+
{{/if}}
|
|
12
17
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
13
18
|
import { createFileRoute } from "@tanstack/react-router";
|
|
14
19
|
import { Loader2, Trash2 } from "lucide-react";
|
|
@@ -19,10 +24,16 @@ export const Route = createFileRoute("/todos")({
|
|
|
19
24
|
});
|
|
20
25
|
|
|
21
26
|
function TodosRoute() {
|
|
27
|
+
{{#if (eq api "trpc")}}
|
|
22
28
|
const trpc = useTRPC();
|
|
29
|
+
{{/if}}
|
|
30
|
+
{{#if (eq api "orpc")}}
|
|
31
|
+
const orpc = useORPC();
|
|
32
|
+
{{/if}}
|
|
23
33
|
|
|
24
34
|
const [newTodoText, setNewTodoText] = useState("");
|
|
25
35
|
|
|
36
|
+
{{#if (eq api "trpc")}}
|
|
26
37
|
const todos = useQuery(trpc.todo.getAll.queryOptions());
|
|
27
38
|
const createMutation = useMutation(
|
|
28
39
|
trpc.todo.create.mutationOptions({
|
|
@@ -42,6 +53,28 @@ function TodosRoute() {
|
|
|
42
53
|
onSuccess: () => todos.refetch(),
|
|
43
54
|
}),
|
|
44
55
|
);
|
|
56
|
+
{{/if}}
|
|
57
|
+
{{#if (eq api "orpc")}}
|
|
58
|
+
const todos = useQuery(orpc.todo.getAll.queryOptions());
|
|
59
|
+
const createMutation = useMutation(
|
|
60
|
+
orpc.todo.create.mutationOptions({
|
|
61
|
+
onSuccess: () => {
|
|
62
|
+
todos.refetch();
|
|
63
|
+
setNewTodoText("");
|
|
64
|
+
},
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
67
|
+
const toggleMutation = useMutation(
|
|
68
|
+
orpc.todo.toggle.mutationOptions({
|
|
69
|
+
onSuccess: () => todos.refetch(),
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
const deleteMutation = useMutation(
|
|
73
|
+
orpc.todo.delete.mutationOptions({
|
|
74
|
+
onSuccess: () => todos.refetch(),
|
|
75
|
+
}),
|
|
76
|
+
);
|
|
77
|
+
{{/if}}
|
|
45
78
|
|
|
46
79
|
const handleAddTodo = (e: React.FormEvent) => {
|
|
47
80
|
e.preventDefault();
|
|
@@ -15,8 +15,6 @@
|
|
|
15
15
|
"@radix-ui/react-slot": "^1.2.0",
|
|
16
16
|
"@tanstack/react-form": "^1.3.2",
|
|
17
17
|
"@tanstack/react-query": "^5.72.2",
|
|
18
|
-
"@trpc/client": "^11.1.0",
|
|
19
|
-
"@trpc/tanstack-react-query": "^11.1.0",
|
|
20
18
|
"class-variance-authority": "^0.7.1",
|
|
21
19
|
"clsx": "^2.1.1",
|
|
22
20
|
"lucide-react": "^0.487.0",
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
"use client"
|
|
2
|
+
{{#if (eq api "orpc")}}
|
|
3
|
+
import { orpc } from "@/utils/orpc";
|
|
4
|
+
{{/if}}
|
|
5
|
+
{{#if (eq api "trpc")}}
|
|
2
6
|
import { trpc } from "@/utils/trpc";
|
|
7
|
+
{{/if}}
|
|
3
8
|
import { useQuery } from "@tanstack/react-query";
|
|
4
9
|
|
|
5
10
|
const TITLE_TEXT = `
|
|
@@ -19,7 +24,12 @@ const TITLE_TEXT = `
|
|
|
19
24
|
`;
|
|
20
25
|
|
|
21
26
|
export default function Home() {
|
|
27
|
+
{{#if (eq api "orpc")}}
|
|
28
|
+
const healthCheck = useQuery(orpc.healthCheck.queryOptions());
|
|
29
|
+
{{/if}}
|
|
30
|
+
{{#if (eq api "trpc")}}
|
|
22
31
|
const healthCheck = useQuery(trpc.healthCheck.queryOptions());
|
|
32
|
+
{{/if}}
|
|
23
33
|
|
|
24
34
|
return (
|
|
25
35
|
<div className="container mx-auto max-w-3xl px-4 py-2">
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { QueryClientProvider } from "@tanstack/react-query";
|
|
3
|
+
{{#if (eq api "orpc")}}
|
|
4
|
+
import { orpc, ORPCContext, queryClient } from "@/utils/orpc";
|
|
5
|
+
{{/if}}
|
|
6
|
+
{{#if (eq api "trpc")}}
|
|
3
7
|
import { queryClient } from "@/utils/trpc";
|
|
8
|
+
{{/if}}
|
|
4
9
|
import { ThemeProvider } from "./theme-provider";
|
|
5
10
|
import { Toaster } from "./ui/sonner";
|
|
6
11
|
|
|
@@ -17,7 +22,14 @@ export default function Providers({
|
|
|
17
22
|
disableTransitionOnChange
|
|
18
23
|
>
|
|
19
24
|
<QueryClientProvider client={queryClient}>
|
|
25
|
+
{{#if (eq api "orpc")}}
|
|
26
|
+
<ORPCContext.Provider value={orpc}>
|
|
27
|
+
{children}
|
|
28
|
+
</ORPCContext.Provider>
|
|
29
|
+
{{/if}}
|
|
30
|
+
{{#if (eq api "trpc")}}
|
|
20
31
|
{children}
|
|
32
|
+
{{/if}}
|
|
21
33
|
</QueryClientProvider>
|
|
22
34
|
<Toaster richColors />
|
|
23
35
|
</ThemeProvider>
|
package/{template/base/apps/web-react-router → templates/frontend/react-router}/package.json
RENAMED
|
@@ -18,9 +18,6 @@
|
|
|
18
18
|
"@react-router/serve": "^7.4.1",
|
|
19
19
|
"@tanstack/react-form": "^1.2.3",
|
|
20
20
|
"@tanstack/react-query": "^5.71.3",
|
|
21
|
-
"@trpc/client": "^11.0.1",
|
|
22
|
-
"@trpc/server": "^11.0.1",
|
|
23
|
-
"@trpc/tanstack-react-query": "^11.0.1",
|
|
24
21
|
"class-variance-authority": "^0.7.1",
|
|
25
22
|
"clsx": "^2.1.1",
|
|
26
23
|
"isbot": "^5.1.17",
|