tvi-cli 0.1.4
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/README.md +147 -0
- package/dist/index.js +4315 -0
- package/package.json +75 -0
- package/templates/addons/biome/biome.json.hbs +83 -0
- package/templates/addons/husky/.husky/pre-commit +1 -0
- package/templates/addons/pwa/apps/web/next/public/favicon/apple-touch-icon.png +0 -0
- package/templates/addons/pwa/apps/web/next/public/favicon/favicon-96x96.png +0 -0
- package/templates/addons/pwa/apps/web/next/public/favicon/favicon.svg +6 -0
- package/templates/addons/pwa/apps/web/next/public/favicon/site.webmanifest.hbs +21 -0
- package/templates/addons/pwa/apps/web/next/public/favicon/web-app-manifest-192x192.png +0 -0
- package/templates/addons/pwa/apps/web/next/public/favicon/web-app-manifest-512x512.png +0 -0
- package/templates/addons/pwa/apps/web/next/src/app/manifest.ts.hbs +26 -0
- package/templates/addons/pwa/apps/web/vite/public/logo.png +0 -0
- package/templates/addons/pwa/apps/web/vite/pwa-assets.config.ts.hbs +12 -0
- package/templates/addons/turborepo/turbo.json.hbs +43 -0
- package/templates/api/orpc/native/utils/orpc.ts.hbs +35 -0
- package/templates/api/orpc/server/base/src/lib/context.ts.hbs +125 -0
- package/templates/api/orpc/server/base/src/lib/orpc.ts.hbs +21 -0
- package/templates/api/orpc/server/next/src/app/rpc/[...all]/route.ts.hbs +23 -0
- package/templates/api/orpc/web/nuxt/app/plugins/orpc.ts.hbs +35 -0
- package/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs +42 -0
- package/templates/api/orpc/web/solid/src/utils/orpc.ts.hbs +30 -0
- package/templates/api/orpc/web/svelte/src/lib/orpc.ts.hbs +31 -0
- package/templates/api/trpc/native/utils/trpc.ts.hbs +32 -0
- package/templates/api/trpc/server/base/src/lib/context.ts.hbs +127 -0
- package/templates/api/trpc/server/base/src/lib/trpc.ts.hbs +26 -0
- package/templates/api/trpc/server/next/src/app/trpc/[trpc]/route.ts +14 -0
- package/templates/api/trpc/web/react/base/src/utils/trpc.ts.hbs +97 -0
- package/templates/auth/native/native-base/lib/auth-client.ts.hbs +13 -0
- package/templates/auth/native/nativewind/app/(drawer)/index.tsx.hbs +95 -0
- package/templates/auth/native/nativewind/components/sign-in.tsx.hbs +93 -0
- package/templates/auth/native/nativewind/components/sign-up.tsx.hbs +104 -0
- package/templates/auth/native/unistyles/app/(drawer)/index.tsx.hbs +179 -0
- package/templates/auth/native/unistyles/components/sign-in.tsx.hbs +134 -0
- package/templates/auth/native/unistyles/components/sign-up.tsx.hbs +152 -0
- package/templates/auth/server/base/src/lib/auth.ts.hbs +141 -0
- package/templates/auth/server/db/drizzle/mysql/src/db/schema/auth.ts +58 -0
- package/templates/auth/server/db/drizzle/postgres/src/db/schema/auth.ts +47 -0
- package/templates/auth/server/db/drizzle/sqlite/src/db/schema/auth.ts +55 -0
- package/templates/auth/server/db/mongoose/mongodb/src/db/models/auth.model.ts +68 -0
- package/templates/auth/server/db/prisma/mongodb/prisma/schema/auth.prisma +59 -0
- package/templates/auth/server/db/prisma/mysql/prisma/schema/auth.prisma +59 -0
- package/templates/auth/server/db/prisma/postgres/prisma/schema/auth.prisma +59 -0
- package/templates/auth/server/db/prisma/sqlite/prisma/schema/auth.prisma +59 -0
- package/templates/auth/server/next/src/app/api/auth/[...all]/route.ts +4 -0
- package/templates/auth/web/nuxt/app/components/SignInForm.vue +77 -0
- package/templates/auth/web/nuxt/app/components/SignUpForm.vue +84 -0
- package/templates/auth/web/nuxt/app/components/UserMenu.vue +42 -0
- package/templates/auth/web/nuxt/app/middleware/auth.ts +12 -0
- package/templates/auth/web/nuxt/app/pages/dashboard.vue +27 -0
- package/templates/auth/web/nuxt/app/pages/login.vue +24 -0
- package/templates/auth/web/nuxt/app/plugins/auth-client.ts +16 -0
- package/templates/auth/web/react/base/src/lib/auth-client.ts.hbs +10 -0
- package/templates/auth/web/react/next/src/app/dashboard/page.tsx.hbs +47 -0
- package/templates/auth/web/react/next/src/app/login/page.tsx +16 -0
- package/templates/auth/web/react/next/src/components/sign-in-form.tsx +135 -0
- package/templates/auth/web/react/next/src/components/sign-up-form.tsx +160 -0
- package/templates/auth/web/react/next/src/components/theme-provider.tsx +11 -0
- package/templates/auth/web/react/next/src/components/user-menu.tsx +60 -0
- package/templates/auth/web/react/react-router/src/components/sign-in-form.tsx +135 -0
- package/templates/auth/web/react/react-router/src/components/sign-up-form.tsx +160 -0
- package/templates/auth/web/react/react-router/src/components/user-menu.tsx +60 -0
- package/templates/auth/web/react/react-router/src/routes/dashboard.tsx.hbs +40 -0
- package/templates/auth/web/react/react-router/src/routes/login.tsx +13 -0
- package/templates/auth/web/react/tanstack-router/src/components/sign-in-form.tsx +139 -0
- package/templates/auth/web/react/tanstack-router/src/components/sign-up-form.tsx +164 -0
- package/templates/auth/web/react/tanstack-router/src/components/user-menu.tsx +62 -0
- package/templates/auth/web/react/tanstack-router/src/routes/dashboard.tsx.hbs +47 -0
- package/templates/auth/web/react/tanstack-router/src/routes/login.tsx +18 -0
- package/templates/auth/web/react/tanstack-start/src/components/sign-in-form.tsx +139 -0
- package/templates/auth/web/react/tanstack-start/src/components/sign-up-form.tsx +164 -0
- package/templates/auth/web/react/tanstack-start/src/components/user-menu.tsx +62 -0
- package/templates/auth/web/react/tanstack-start/src/routes/dashboard.tsx.hbs +51 -0
- package/templates/auth/web/react/tanstack-start/src/routes/login.tsx +18 -0
- package/templates/auth/web/solid/src/components/sign-in-form.tsx +132 -0
- package/templates/auth/web/solid/src/components/sign-up-form.tsx +158 -0
- package/templates/auth/web/solid/src/components/user-menu.tsx.hbs +55 -0
- package/templates/auth/web/solid/src/lib/auth-client.ts +5 -0
- package/templates/auth/web/solid/src/routes/dashboard.tsx +38 -0
- package/templates/auth/web/solid/src/routes/login.tsx +23 -0
- package/templates/auth/web/svelte/src/components/SignInForm.svelte +108 -0
- package/templates/auth/web/svelte/src/components/SignUpForm.svelte +142 -0
- package/templates/auth/web/svelte/src/components/UserMenu.svelte +54 -0
- package/templates/auth/web/svelte/src/lib/auth-client.ts +6 -0
- package/templates/auth/web/svelte/src/routes/dashboard/+page.svelte +31 -0
- package/templates/auth/web/svelte/src/routes/login/+page.svelte +12 -0
- package/templates/backend/convex/packages/backend/_gitignore +2 -0
- package/templates/backend/convex/packages/backend/convex/README.md +90 -0
- package/templates/backend/convex/packages/backend/convex/healthCheck.ts +7 -0
- package/templates/backend/convex/packages/backend/convex/schema.ts +9 -0
- package/templates/backend/convex/packages/backend/convex/todos.ts +42 -0
- package/templates/backend/convex/packages/backend/convex/tsconfig.json +25 -0
- package/templates/backend/convex/packages/backend/package.json.hbs +17 -0
- package/templates/backend/server/elysia/src/index.ts.hbs +72 -0
- package/templates/backend/server/express/src/index.ts.hbs +88 -0
- package/templates/backend/server/fastify/src/index.ts.hbs +155 -0
- package/templates/backend/server/hono/src/index.ts.hbs +133 -0
- package/templates/backend/server/next/next-env.d.ts +5 -0
- package/templates/backend/server/next/next.config.ts +7 -0
- package/templates/backend/server/next/package.json.hbs +24 -0
- package/templates/backend/server/next/src/app/route.ts +5 -0
- package/templates/backend/server/next/src/middleware.ts +19 -0
- package/templates/backend/server/next/tsconfig.json.hbs +33 -0
- package/templates/backend/server/server-base/_gitignore +52 -0
- package/templates/backend/server/server-base/package.json.hbs +28 -0
- package/templates/backend/server/server-base/src/routers/index.ts.hbs +53 -0
- package/templates/backend/server/server-base/tsconfig.json.hbs +39 -0
- package/templates/base/_gitignore +2 -0
- package/templates/base/package.json.hbs +11 -0
- package/templates/db/drizzle/mysql/drizzle.config.ts.hbs +10 -0
- package/templates/db/drizzle/mysql/src/db/index.ts.hbs +20 -0
- package/templates/db/drizzle/postgres/drizzle.config.ts.hbs +10 -0
- package/templates/db/drizzle/postgres/src/db/index.ts.hbs +12 -0
- package/templates/db/drizzle/sqlite/drizzle.config.ts.hbs +24 -0
- package/templates/db/drizzle/sqlite/src/db/index.ts.hbs +35 -0
- package/templates/db/mongoose/mongodb/src/db/index.ts.hbs +9 -0
- package/templates/db/prisma/mongodb/prisma/index.ts.hbs +5 -0
- package/templates/db/prisma/mongodb/prisma/schema/schema.prisma +10 -0
- package/templates/db/prisma/mongodb/prisma.config.ts.hbs +8 -0
- package/templates/db/prisma/mysql/prisma/index.ts +5 -0
- package/templates/db/prisma/mysql/prisma/schema/schema.prisma +10 -0
- package/templates/db/prisma/mysql/prisma.config.ts +8 -0
- package/templates/db/prisma/postgres/prisma/index.ts +5 -0
- package/templates/db/prisma/postgres/prisma/schema/schema.prisma.hbs +13 -0
- package/templates/db/prisma/postgres/prisma.config.ts.hbs +12 -0
- package/templates/db/prisma/sqlite/prisma/index.ts +5 -0
- package/templates/db/prisma/sqlite/prisma/schema/schema.prisma +10 -0
- package/templates/db/prisma/sqlite/prisma.config.ts +8 -0
- package/templates/examples/ai/native/nativewind/app/(drawer)/ai.tsx.hbs +155 -0
- package/templates/examples/ai/native/nativewind/polyfills.js +25 -0
- package/templates/examples/ai/native/unistyles/app/(drawer)/ai.tsx.hbs +279 -0
- package/templates/examples/ai/native/unistyles/polyfills.js +25 -0
- package/templates/examples/ai/server/next/src/app/ai/route.ts +15 -0
- package/templates/examples/ai/web/nuxt/app/pages/ai.vue +63 -0
- package/templates/examples/ai/web/react/next/src/app/ai/page.tsx +67 -0
- package/templates/examples/ai/web/react/react-router/src/routes/ai.tsx +64 -0
- package/templates/examples/ai/web/react/tanstack-router/src/routes/ai.tsx +69 -0
- package/templates/examples/ai/web/react/tanstack-start/src/routes/ai.tsx +69 -0
- package/templates/examples/ai/web/svelte/src/routes/ai/+page.svelte +98 -0
- package/templates/examples/todo/native/nativewind/app/(drawer)/todos.tsx.hbs +295 -0
- package/templates/examples/todo/native/unistyles/app/(drawer)/todos.tsx.hbs +340 -0
- package/templates/examples/todo/server/drizzle/base/src/routers/todo.ts.hbs +79 -0
- package/templates/examples/todo/server/drizzle/mysql/src/db/schema/todo.ts +7 -0
- package/templates/examples/todo/server/drizzle/postgres/src/db/schema/todo.ts +7 -0
- package/templates/examples/todo/server/drizzle/sqlite/src/db/schema/todo.ts +7 -0
- package/templates/examples/todo/server/mongoose/base/src/routers/todo.ts.hbs +66 -0
- package/templates/examples/todo/server/mongoose/mongodb/src/db/models/todo.model.ts +24 -0
- package/templates/examples/todo/server/prisma/base/src/routers/todo.ts.hbs +118 -0
- package/templates/examples/todo/server/prisma/mongodb/prisma/schema/todo.prisma +7 -0
- package/templates/examples/todo/server/prisma/mysql/prisma/schema/todo.prisma +7 -0
- package/templates/examples/todo/server/prisma/postgres/prisma/schema/todo.prisma +7 -0
- package/templates/examples/todo/server/prisma/sqlite/prisma/schema/todo.prisma +7 -0
- package/templates/examples/todo/web/nuxt/app/pages/todos.vue +108 -0
- package/templates/examples/todo/web/react/next/src/app/todos/page.tsx.hbs +245 -0
- package/templates/examples/todo/web/react/react-router/src/routes/todos.tsx.hbs +242 -0
- package/templates/examples/todo/web/react/tanstack-router/src/routes/todos.tsx.hbs +247 -0
- package/templates/examples/todo/web/react/tanstack-start/src/routes/todos.tsx.hbs +268 -0
- package/templates/examples/todo/web/solid/src/routes/todos.tsx.hbs +132 -0
- package/templates/examples/todo/web/svelte/src/routes/todos/+page.svelte.hbs +317 -0
- package/templates/extras/_npmrc.hbs +5 -0
- package/templates/extras/pnpm-workspace.yaml +3 -0
- package/templates/frontend/native/native-base/assets/adaptive-icon.png +0 -0
- package/templates/frontend/native/native-base/assets/favicon.png +0 -0
- package/templates/frontend/native/native-base/assets/icon.png +0 -0
- package/templates/frontend/native/native-base/assets/splash.png +0 -0
- package/templates/frontend/native/nativewind/_gitignore +25 -0
- package/templates/frontend/native/nativewind/app/(drawer)/(tabs)/_layout.tsx +46 -0
- package/templates/frontend/native/nativewind/app/(drawer)/(tabs)/index.tsx +19 -0
- package/templates/frontend/native/nativewind/app/(drawer)/(tabs)/two.tsx +19 -0
- package/templates/frontend/native/nativewind/app/(drawer)/_layout.tsx.hbs +67 -0
- package/templates/frontend/native/nativewind/app/(drawer)/index.tsx.hbs +95 -0
- package/templates/frontend/native/nativewind/app/+html.tsx +47 -0
- package/templates/frontend/native/nativewind/app/+not-found.tsx +29 -0
- package/templates/frontend/native/nativewind/app/_layout.tsx.hbs +126 -0
- package/templates/frontend/native/nativewind/app/modal.tsx +14 -0
- package/templates/frontend/native/nativewind/app-env.d.ts +2 -0
- package/templates/frontend/native/nativewind/app.json +46 -0
- package/templates/frontend/native/nativewind/babel.config.js +11 -0
- package/templates/frontend/native/nativewind/components/container.tsx +8 -0
- package/templates/frontend/native/nativewind/components/header-button.tsx +26 -0
- package/templates/frontend/native/nativewind/components/tabbar-icon.tsx +8 -0
- package/templates/frontend/native/nativewind/global.css +50 -0
- package/templates/frontend/native/nativewind/lib/android-navigation-bar.tsx +11 -0
- package/templates/frontend/native/nativewind/lib/constants.ts +18 -0
- package/templates/frontend/native/nativewind/lib/use-color-scheme.ts +12 -0
- package/templates/frontend/native/nativewind/metro.config.js +59 -0
- package/templates/frontend/native/nativewind/package.json.hbs +49 -0
- package/templates/frontend/native/nativewind/tailwind.config.js +59 -0
- package/templates/frontend/native/nativewind/tsconfig.json.hbs +23 -0
- package/templates/frontend/native/unistyles/_gitignore +24 -0
- package/templates/frontend/native/unistyles/app/(drawer)/(tabs)/_layout.tsx +39 -0
- package/templates/frontend/native/unistyles/app/(drawer)/(tabs)/index.tsx +37 -0
- package/templates/frontend/native/unistyles/app/(drawer)/(tabs)/two.tsx +37 -0
- package/templates/frontend/native/unistyles/app/(drawer)/_layout.tsx.hbs +87 -0
- package/templates/frontend/native/unistyles/app/(drawer)/index.tsx.hbs +194 -0
- package/templates/frontend/native/unistyles/app/+html.tsx +48 -0
- package/templates/frontend/native/unistyles/app/+not-found.tsx +65 -0
- package/templates/frontend/native/unistyles/app/_layout.tsx.hbs +104 -0
- package/templates/frontend/native/unistyles/app/modal.tsx +33 -0
- package/templates/frontend/native/unistyles/app.json +44 -0
- package/templates/frontend/native/unistyles/babel.config.js +20 -0
- package/templates/frontend/native/unistyles/breakpoints.ts +9 -0
- package/templates/frontend/native/unistyles/components/container.tsx +15 -0
- package/templates/frontend/native/unistyles/components/header-button.tsx +36 -0
- package/templates/frontend/native/unistyles/components/tabbar-icon.tsx +8 -0
- package/templates/frontend/native/unistyles/expo-env.d.ts +3 -0
- package/templates/frontend/native/unistyles/index.js +2 -0
- package/templates/frontend/native/unistyles/metro.config.js +20 -0
- package/templates/frontend/native/unistyles/package.json.hbs +50 -0
- package/templates/frontend/native/unistyles/theme.ts +98 -0
- package/templates/frontend/native/unistyles/tsconfig.json.hbs +17 -0
- package/templates/frontend/native/unistyles/unistyles.ts +27 -0
- package/templates/frontend/nuxt/_gitignore +24 -0
- package/templates/frontend/nuxt/app/app.config.ts +15 -0
- package/templates/frontend/nuxt/app/app.vue +13 -0
- package/templates/frontend/nuxt/app/assets/css/main.css +2 -0
- package/templates/frontend/nuxt/app/components/Header.vue.hbs +45 -0
- package/templates/frontend/nuxt/app/components/Loader.vue +5 -0
- package/templates/frontend/nuxt/app/components/ModeToggle.vue +23 -0
- package/templates/frontend/nuxt/app/layouts/default.vue.hbs +11 -0
- package/templates/frontend/nuxt/app/pages/index.vue.hbs +57 -0
- package/templates/frontend/nuxt/app/plugins/vue-query.ts.hbs +44 -0
- package/templates/frontend/nuxt/nuxt.config.ts.hbs +19 -0
- package/templates/frontend/nuxt/package.json.hbs +25 -0
- package/templates/frontend/nuxt/public/favicon.ico +0 -0
- package/templates/frontend/nuxt/public/robots.txt +2 -0
- package/templates/frontend/nuxt/server/tsconfig.json +3 -0
- package/templates/frontend/nuxt/tsconfig.json.hbs +9 -0
- package/templates/frontend/react/next/next-env.d.ts.hbs +5 -0
- package/templates/frontend/react/next/next.config.ts.hbs +5 -0
- package/templates/frontend/react/next/package.json.hbs +34 -0
- package/templates/frontend/react/next/postcss.config.mjs.hbs +5 -0
- package/templates/frontend/react/next/src/app/favicon.ico +0 -0
- package/templates/frontend/react/next/src/app/layout.tsx.hbs +41 -0
- package/templates/frontend/react/next/src/app/page.tsx.hbs +68 -0
- package/templates/frontend/react/next/src/components/mode-toggle.tsx.hbs +39 -0
- package/templates/frontend/react/next/src/components/providers.tsx.hbs +56 -0
- package/templates/frontend/react/next/src/components/theme-provider.tsx.hbs +11 -0
- package/templates/frontend/react/next/tsconfig.json.hbs +33 -0
- package/templates/frontend/react/react-router/package.json.hbs +42 -0
- package/templates/frontend/react/react-router/public/favicon.ico +0 -0
- package/templates/frontend/react/react-router/react-router.config.ts +6 -0
- package/templates/frontend/react/react-router/src/components/mode-toggle.tsx +37 -0
- package/templates/frontend/react/react-router/src/components/theme-provider.tsx +73 -0
- package/templates/frontend/react/react-router/src/root.tsx.hbs +152 -0
- package/templates/frontend/react/react-router/src/routes/_index.tsx.hbs +74 -0
- package/templates/frontend/react/react-router/src/routes.ts +4 -0
- package/templates/frontend/react/react-router/tsconfig.json.hbs +32 -0
- package/templates/frontend/react/react-router/vite.config.ts.hbs +33 -0
- package/templates/frontend/react/tanstack-router/index.html +12 -0
- package/templates/frontend/react/tanstack-router/package.json.hbs +41 -0
- package/templates/frontend/react/tanstack-router/src/components/mode-toggle.tsx +37 -0
- package/templates/frontend/react/tanstack-router/src/components/theme-provider.tsx +73 -0
- package/templates/frontend/react/tanstack-router/src/main.tsx.hbs +66 -0
- package/templates/frontend/react/tanstack-router/src/routes/__root.tsx.hbs +100 -0
- package/templates/frontend/react/tanstack-router/src/routes/index.tsx.hbs +74 -0
- package/templates/frontend/react/tanstack-router/tsconfig.json.hbs +23 -0
- package/templates/frontend/react/tanstack-router/vite.config.ts.hbs +39 -0
- package/templates/frontend/react/tanstack-start/package.json.hbs +44 -0
- package/templates/frontend/react/tanstack-start/public/robots.txt +3 -0
- package/templates/frontend/react/tanstack-start/src/router.tsx.hbs +144 -0
- package/templates/frontend/react/tanstack-start/src/routes/__root.tsx.hbs +97 -0
- package/templates/frontend/react/tanstack-start/src/routes/index.tsx.hbs +74 -0
- package/templates/frontend/react/tanstack-start/tsconfig.json.hbs +33 -0
- package/templates/frontend/react/tanstack-start/vite.config.ts +8 -0
- package/templates/frontend/react/web-base/_gitignore +52 -0
- package/templates/frontend/react/web-base/components.json +21 -0
- package/templates/frontend/react/web-base/src/components/header.tsx.hbs +79 -0
- package/templates/frontend/react/web-base/src/components/loader.tsx +9 -0
- package/templates/frontend/react/web-base/src/components/ui/button.tsx +59 -0
- package/templates/frontend/react/web-base/src/components/ui/card.tsx +92 -0
- package/templates/frontend/react/web-base/src/components/ui/checkbox.tsx +30 -0
- package/templates/frontend/react/web-base/src/components/ui/dropdown-menu.tsx +257 -0
- package/templates/frontend/react/web-base/src/components/ui/input.tsx +21 -0
- package/templates/frontend/react/web-base/src/components/ui/label.tsx +22 -0
- package/templates/frontend/react/web-base/src/components/ui/skeleton.tsx +13 -0
- package/templates/frontend/react/web-base/src/components/ui/sonner.tsx +25 -0
- package/templates/frontend/react/web-base/src/index.css +134 -0
- package/templates/frontend/react/web-base/src/lib/utils.ts +6 -0
- package/templates/frontend/solid/_gitignore +7 -0
- package/templates/frontend/solid/index.html +13 -0
- package/templates/frontend/solid/package.json.hbs +27 -0
- package/templates/frontend/solid/public/robots.txt +3 -0
- package/templates/frontend/solid/src/components/header.tsx.hbs +38 -0
- package/templates/frontend/solid/src/components/loader.tsx +9 -0
- package/templates/frontend/solid/src/main.tsx.hbs +38 -0
- package/templates/frontend/solid/src/routes/__root.tsx.hbs +34 -0
- package/templates/frontend/solid/src/routes/index.tsx.hbs +61 -0
- package/templates/frontend/solid/src/styles.css +5 -0
- package/templates/frontend/solid/tsconfig.json.hbs +34 -0
- package/templates/frontend/solid/vite.config.js.hbs +39 -0
- package/templates/frontend/svelte/_gitignore +23 -0
- package/templates/frontend/svelte/_npmrc +1 -0
- package/templates/frontend/svelte/package.json.hbs +31 -0
- package/templates/frontend/svelte/src/app.css +5 -0
- package/templates/frontend/svelte/src/app.d.ts +13 -0
- package/templates/frontend/svelte/src/app.html +12 -0
- package/templates/frontend/svelte/src/components/Header.svelte.hbs +40 -0
- package/templates/frontend/svelte/src/lib/index.ts +1 -0
- package/templates/frontend/svelte/src/routes/+layout.svelte.hbs +54 -0
- package/templates/frontend/svelte/src/routes/+page.svelte.hbs +72 -0
- package/templates/frontend/svelte/static/favicon.png +0 -0
- package/templates/frontend/svelte/svelte.config.js +18 -0
- package/templates/frontend/svelte/tsconfig.json.hbs +24 -0
- package/templates/frontend/svelte/vite.config.ts +7 -0
- package/templates/runtime/workers/apps/server/wrangler.jsonc.hbs +34 -0
@@ -0,0 +1,12 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8" />
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6
|
+
</head>
|
7
|
+
|
8
|
+
<body>
|
9
|
+
<div id="app"></div>
|
10
|
+
<script type="module" src="/src/main.tsx"></script>
|
11
|
+
</body>
|
12
|
+
</html>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
{
|
2
|
+
"name": "web",
|
3
|
+
"version": "0.0.0",
|
4
|
+
"private": true,
|
5
|
+
"type": "module",
|
6
|
+
"scripts": {
|
7
|
+
"dev": "vite --port=3001",
|
8
|
+
"build": "vite build",
|
9
|
+
"serve": "vite preview",
|
10
|
+
"start": "vite",
|
11
|
+
"check-types": "tsc --noEmit"
|
12
|
+
},
|
13
|
+
"devDependencies": {
|
14
|
+
"@tanstack/react-router-devtools": "^1.114.27",
|
15
|
+
"@tanstack/router-plugin": "^1.114.27",
|
16
|
+
"@types/node": "^22.13.13",
|
17
|
+
"@types/react": "^19.0.12",
|
18
|
+
"@types/react-dom": "^19.0.4",
|
19
|
+
"@vitejs/plugin-react": "^4.3.4",
|
20
|
+
"postcss": "^8.5.3",
|
21
|
+
"tailwindcss": "^4.0.15",
|
22
|
+
"vite": "^6.2.2"
|
23
|
+
},
|
24
|
+
"dependencies": {
|
25
|
+
"@hookform/resolvers": "^5.1.1",
|
26
|
+
"radix-ui": "^1.4.2",
|
27
|
+
"@tanstack/react-form": "^1.12.3",
|
28
|
+
"@tailwindcss/vite": "^4.0.15",
|
29
|
+
"@tanstack/react-router": "^1.114.25",
|
30
|
+
"class-variance-authority": "^0.7.1",
|
31
|
+
"clsx": "^2.1.1",
|
32
|
+
"lucide-react": "^0.473.0",
|
33
|
+
"next-themes": "^0.4.6",
|
34
|
+
"react": "^19.0.0",
|
35
|
+
"react-dom": "^19.0.0",
|
36
|
+
"sonner": "^2.0.5",
|
37
|
+
"tailwind-merge": "^3.3.1",
|
38
|
+
"tw-animate-css": "^1.2.5",
|
39
|
+
"zod": "^3.25.16"
|
40
|
+
}
|
41
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { Moon, Sun } from "lucide-react";
|
2
|
+
|
3
|
+
import { Button } from "@/components/ui/button";
|
4
|
+
import {
|
5
|
+
DropdownMenu,
|
6
|
+
DropdownMenuContent,
|
7
|
+
DropdownMenuItem,
|
8
|
+
DropdownMenuTrigger,
|
9
|
+
} from "@/components/ui/dropdown-menu";
|
10
|
+
import { useTheme } from "@/components/theme-provider";
|
11
|
+
|
12
|
+
export function ModeToggle() {
|
13
|
+
const { setTheme } = useTheme();
|
14
|
+
|
15
|
+
return (
|
16
|
+
<DropdownMenu>
|
17
|
+
<DropdownMenuTrigger asChild>
|
18
|
+
<Button variant="outline" size="icon">
|
19
|
+
<Sun className="h-[1.2rem] w-[1.2rem] scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90" />
|
20
|
+
<Moon className="absolute h-[1.2rem] w-[1.2rem] scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0" />
|
21
|
+
<span className="sr-only">Toggle theme</span>
|
22
|
+
</Button>
|
23
|
+
</DropdownMenuTrigger>
|
24
|
+
<DropdownMenuContent align="end">
|
25
|
+
<DropdownMenuItem onClick={() => setTheme("light")}>
|
26
|
+
Light
|
27
|
+
</DropdownMenuItem>
|
28
|
+
<DropdownMenuItem onClick={() => setTheme("dark")}>
|
29
|
+
Dark
|
30
|
+
</DropdownMenuItem>
|
31
|
+
<DropdownMenuItem onClick={() => setTheme("system")}>
|
32
|
+
System
|
33
|
+
</DropdownMenuItem>
|
34
|
+
</DropdownMenuContent>
|
35
|
+
</DropdownMenu>
|
36
|
+
);
|
37
|
+
}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import { createContext, useContext, useEffect, useState } from "react";
|
2
|
+
|
3
|
+
type Theme = "dark" | "light" | "system";
|
4
|
+
|
5
|
+
type ThemeProviderProps = {
|
6
|
+
children: React.ReactNode;
|
7
|
+
defaultTheme?: Theme;
|
8
|
+
storageKey?: string;
|
9
|
+
};
|
10
|
+
|
11
|
+
type ThemeProviderState = {
|
12
|
+
theme: Theme;
|
13
|
+
setTheme: (theme: Theme) => void;
|
14
|
+
};
|
15
|
+
|
16
|
+
const initialState: ThemeProviderState = {
|
17
|
+
theme: "system",
|
18
|
+
setTheme: () => null,
|
19
|
+
};
|
20
|
+
|
21
|
+
const ThemeProviderContext = createContext<ThemeProviderState>(initialState);
|
22
|
+
|
23
|
+
export function ThemeProvider({
|
24
|
+
children,
|
25
|
+
defaultTheme = "system",
|
26
|
+
storageKey = "vite-ui-theme",
|
27
|
+
...props
|
28
|
+
}: ThemeProviderProps) {
|
29
|
+
const [theme, setTheme] = useState<Theme>(
|
30
|
+
() => (localStorage.getItem(storageKey) as Theme) || defaultTheme
|
31
|
+
);
|
32
|
+
|
33
|
+
useEffect(() => {
|
34
|
+
const root = window.document.documentElement;
|
35
|
+
|
36
|
+
root.classList.remove("light", "dark");
|
37
|
+
|
38
|
+
if (theme === "system") {
|
39
|
+
const systemTheme = window.matchMedia("(prefers-color-scheme: dark)")
|
40
|
+
.matches
|
41
|
+
? "dark"
|
42
|
+
: "light";
|
43
|
+
|
44
|
+
root.classList.add(systemTheme);
|
45
|
+
return;
|
46
|
+
}
|
47
|
+
|
48
|
+
root.classList.add(theme);
|
49
|
+
}, [theme]);
|
50
|
+
|
51
|
+
const value = {
|
52
|
+
theme,
|
53
|
+
setTheme: (theme: Theme) => {
|
54
|
+
localStorage.setItem(storageKey, theme);
|
55
|
+
setTheme(theme);
|
56
|
+
},
|
57
|
+
};
|
58
|
+
|
59
|
+
return (
|
60
|
+
<ThemeProviderContext.Provider {...props} value={value}>
|
61
|
+
{children}
|
62
|
+
</ThemeProviderContext.Provider>
|
63
|
+
);
|
64
|
+
}
|
65
|
+
|
66
|
+
export const useTheme = () => {
|
67
|
+
const context = useContext(ThemeProviderContext);
|
68
|
+
|
69
|
+
if (context === undefined)
|
70
|
+
throw new Error("useTheme must be used within a ThemeProvider");
|
71
|
+
|
72
|
+
return context;
|
73
|
+
};
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import { RouterProvider, createRouter } from "@tanstack/react-router";
|
2
|
+
import ReactDOM from "react-dom/client";
|
3
|
+
import Loader from "./components/loader";
|
4
|
+
import { routeTree } from "./routeTree.gen";
|
5
|
+
|
6
|
+
{{#if (eq api "orpc")}}
|
7
|
+
import { QueryClientProvider } from "@tanstack/react-query";
|
8
|
+
import { orpc, queryClient } from "./utils/orpc";
|
9
|
+
{{/if}}
|
10
|
+
{{#if (eq api "trpc")}}
|
11
|
+
import { QueryClientProvider } from "@tanstack/react-query";
|
12
|
+
import { queryClient, trpc } from "./utils/trpc";
|
13
|
+
{{/if}}
|
14
|
+
{{#if (eq backend "convex")}}
|
15
|
+
import { ConvexProvider, ConvexReactClient } from "convex/react";
|
16
|
+
const convex = new ConvexReactClient(import.meta.env.VITE_CONVEX_URL as string);
|
17
|
+
{{/if}}
|
18
|
+
|
19
|
+
const router = createRouter({
|
20
|
+
routeTree,
|
21
|
+
defaultPreload: "intent",
|
22
|
+
defaultPendingComponent: () => <Loader />,
|
23
|
+
{{#if (eq api "orpc")}}
|
24
|
+
context: { orpc, queryClient },
|
25
|
+
Wrap: function WrapComponent({ children }: { children: React.ReactNode }) {
|
26
|
+
return (
|
27
|
+
<QueryClientProvider client={queryClient}>
|
28
|
+
{children}
|
29
|
+
</QueryClientProvider>
|
30
|
+
);
|
31
|
+
},
|
32
|
+
{{else if (eq api "trpc")}}
|
33
|
+
context: { trpc, queryClient },
|
34
|
+
Wrap: function WrapComponent({ children }: { children: React.ReactNode }) {
|
35
|
+
return (
|
36
|
+
<QueryClientProvider client={queryClient}>
|
37
|
+
{children}
|
38
|
+
</QueryClientProvider>
|
39
|
+
);
|
40
|
+
},
|
41
|
+
{{else if (eq backend "convex")}}
|
42
|
+
context: {},
|
43
|
+
Wrap: function WrapComponent({ children }: { children: React.ReactNode }) {
|
44
|
+
return <ConvexProvider client={convex}>{children}</ConvexProvider>;
|
45
|
+
},
|
46
|
+
{{else}}
|
47
|
+
context: {},
|
48
|
+
{{/if}}
|
49
|
+
});
|
50
|
+
|
51
|
+
declare module "@tanstack/react-router" {
|
52
|
+
interface Register {
|
53
|
+
router: typeof router;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
const rootElement = document.getElementById("app");
|
58
|
+
|
59
|
+
if (!rootElement) {
|
60
|
+
throw new Error("Root element not found");
|
61
|
+
}
|
62
|
+
|
63
|
+
if (!rootElement.innerHTML) {
|
64
|
+
const root = ReactDOM.createRoot(rootElement);
|
65
|
+
root.render(<RouterProvider router={router} />);
|
66
|
+
}
|
@@ -0,0 +1,100 @@
|
|
1
|
+
import Header from "@/components/header";
|
2
|
+
import Loader from "@/components/loader";
|
3
|
+
import { ThemeProvider } from "@/components/theme-provider";
|
4
|
+
import { Toaster } from "@/components/ui/sonner";
|
5
|
+
{{#if (eq api "orpc")}}
|
6
|
+
import { link, orpc } from "@/utils/orpc";
|
7
|
+
import type { QueryClient } from "@tanstack/react-query";
|
8
|
+
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
9
|
+
import { useState } from "react";
|
10
|
+
import type { RouterClient } from "@orpc/server";
|
11
|
+
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
12
|
+
import type { appRouter } from "../../../server/src/routers";
|
13
|
+
import { createORPCClient } from "@orpc/client";
|
14
|
+
{{/if}}
|
15
|
+
{{#if (eq api "trpc")}}
|
16
|
+
import type { trpc } from "@/utils/trpc";
|
17
|
+
import type { QueryClient } from "@tanstack/react-query";
|
18
|
+
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
19
|
+
{{/if}}
|
20
|
+
import {
|
21
|
+
HeadContent,
|
22
|
+
Outlet,
|
23
|
+
createRootRouteWithContext,
|
24
|
+
useRouterState,
|
25
|
+
} from "@tanstack/react-router";
|
26
|
+
import { TanStackRouterDevtools } from "@tanstack/react-router-devtools";
|
27
|
+
import "../index.css";
|
28
|
+
|
29
|
+
{{#if (eq api "orpc")}}
|
30
|
+
export interface RouterAppContext {
|
31
|
+
orpc: typeof orpc;
|
32
|
+
queryClient: QueryClient;
|
33
|
+
}
|
34
|
+
{{else if (eq api "trpc")}}
|
35
|
+
export interface RouterAppContext {
|
36
|
+
trpc: typeof trpc;
|
37
|
+
queryClient: QueryClient;
|
38
|
+
}
|
39
|
+
{{else}}
|
40
|
+
export interface RouterAppContext {}
|
41
|
+
{{/if}}
|
42
|
+
|
43
|
+
export const Route = createRootRouteWithContext<RouterAppContext>()({
|
44
|
+
component: RootComponent,
|
45
|
+
head: () => ({
|
46
|
+
meta: [
|
47
|
+
{
|
48
|
+
title: "My App",
|
49
|
+
},
|
50
|
+
{
|
51
|
+
name: "description",
|
52
|
+
content: "My App is a web application",
|
53
|
+
},
|
54
|
+
],
|
55
|
+
links: [
|
56
|
+
{
|
57
|
+
rel: "icon",
|
58
|
+
href: "/favicon.ico",
|
59
|
+
},
|
60
|
+
],
|
61
|
+
}),
|
62
|
+
});
|
63
|
+
|
64
|
+
function RootComponent() {
|
65
|
+
const isFetching = useRouterState({
|
66
|
+
select: (s) => s.isLoading,
|
67
|
+
});
|
68
|
+
|
69
|
+
{{#if (eq api "orpc")}}
|
70
|
+
const [client] = useState<RouterClient<typeof appRouter>>(() => createORPCClient(link));
|
71
|
+
const [orpcUtils] = useState(() => createTanstackQueryUtils(client));
|
72
|
+
{{/if}}
|
73
|
+
|
74
|
+
return (
|
75
|
+
<>
|
76
|
+
<HeadContent />
|
77
|
+
{{#if (eq api "orpc")}}
|
78
|
+
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
|
79
|
+
<div className="grid grid-rows-[auto_1fr] h-svh">
|
80
|
+
<Header />
|
81
|
+
{isFetching ? <Loader /> : <Outlet />}
|
82
|
+
</div>
|
83
|
+
<Toaster richColors />
|
84
|
+
</ThemeProvider>
|
85
|
+
{{else}}
|
86
|
+
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
|
87
|
+
<div className="grid grid-rows-[auto_1fr] h-svh">
|
88
|
+
<Header />
|
89
|
+
{isFetching ? <Loader /> : <Outlet />}
|
90
|
+
</div>
|
91
|
+
<Toaster richColors />
|
92
|
+
</ThemeProvider>
|
93
|
+
{{/if}}
|
94
|
+
<TanStackRouterDevtools position="bottom-left" />
|
95
|
+
{{#if (or (eq api "orpc") (eq api "trpc"))}}
|
96
|
+
<ReactQueryDevtools position="bottom" buttonPosition="bottom-right" />
|
97
|
+
{{/if}}
|
98
|
+
</>
|
99
|
+
);
|
100
|
+
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
import { createFileRoute } from "@tanstack/react-router";
|
2
|
+
{{#if (eq api "orpc")}}
|
3
|
+
import { orpc } from "@/utils/orpc";
|
4
|
+
import { useQuery } from "@tanstack/react-query";
|
5
|
+
{{/if}}
|
6
|
+
{{#if (eq api "trpc")}}
|
7
|
+
import { trpc } from "@/utils/trpc";
|
8
|
+
import { useQuery } from "@tanstack/react-query";
|
9
|
+
{{/if}}
|
10
|
+
{{#if (eq backend "convex")}}
|
11
|
+
import { useQuery } from "convex/react";
|
12
|
+
import { api } from "@{{ projectName }}/backend/convex/_generated/api";
|
13
|
+
{{/if}}
|
14
|
+
|
15
|
+
export const Route = createFileRoute("/")({
|
16
|
+
component: HomeComponent,
|
17
|
+
});
|
18
|
+
|
19
|
+
const TITLE_TEXT = `
|
20
|
+
TVI TypeScript Initializer
|
21
|
+
A CLI tool to quickly scaffold TypeScript projects with popular frameworks and libraries.
|
22
|
+
`;
|
23
|
+
|
24
|
+
function HomeComponent() {
|
25
|
+
{{#if (eq api "orpc")}}
|
26
|
+
const healthCheck = useQuery(orpc.healthCheck.queryOptions());
|
27
|
+
{{/if}}
|
28
|
+
{{#if (eq api "trpc")}}
|
29
|
+
const healthCheck = useQuery(trpc.healthCheck.queryOptions());
|
30
|
+
{{/if}}
|
31
|
+
{{#if (eq backend "convex")}}
|
32
|
+
const healthCheck = useQuery(api.healthCheck.get);
|
33
|
+
{{/if}}
|
34
|
+
|
35
|
+
return (
|
36
|
+
<div className="container mx-auto max-w-3xl px-4 py-2">
|
37
|
+
<pre className="overflow-x-auto font-mono text-sm">{TITLE_TEXT}</pre>
|
38
|
+
<div className="grid gap-6">
|
39
|
+
<section className="rounded-lg border p-4">
|
40
|
+
<h2 className="mb-2 font-medium">API Status</h2>
|
41
|
+
{{#if (eq backend "convex")}}
|
42
|
+
<div className="flex items-center gap-2">
|
43
|
+
<div
|
44
|
+
className={`h-2 w-2 rounded-full ${healthCheck === "OK" ? "bg-green-500" : healthCheck === undefined ? "bg-orange-400" : "bg-red-500"}`}
|
45
|
+
/>
|
46
|
+
<span className="text-sm text-muted-foreground">
|
47
|
+
{healthCheck === undefined
|
48
|
+
? "Checking..."
|
49
|
+
: healthCheck === "OK"
|
50
|
+
? "Connected"
|
51
|
+
: "Error"}
|
52
|
+
</span>
|
53
|
+
</div>
|
54
|
+
{{else}}
|
55
|
+
{{#unless (eq api "none")}}
|
56
|
+
<div className="flex items-center gap-2">
|
57
|
+
<div
|
58
|
+
className={`h-2 w-2 rounded-full ${healthCheck.data ? "bg-green-500" : "bg-red-500"}`}
|
59
|
+
/>
|
60
|
+
<span className="text-sm text-muted-foreground">
|
61
|
+
{healthCheck.isLoading
|
62
|
+
? "Checking..."
|
63
|
+
: healthCheck.data
|
64
|
+
? "Connected"
|
65
|
+
: "Disconnected"}
|
66
|
+
</span>
|
67
|
+
</div>
|
68
|
+
{{/unless}}
|
69
|
+
{{/if}}
|
70
|
+
</section>
|
71
|
+
</div>
|
72
|
+
</div>
|
73
|
+
);
|
74
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"strict": true,
|
4
|
+
"esModuleInterop": true,
|
5
|
+
"jsx": "react-jsx",
|
6
|
+
"target": "ESNext",
|
7
|
+
"module": "ESNext",
|
8
|
+
"moduleResolution": "Bundler",
|
9
|
+
"verbatimModuleSyntax": true,
|
10
|
+
"skipLibCheck": true,
|
11
|
+
"types": ["vite/client"],
|
12
|
+
"rootDirs": ["."],
|
13
|
+
"baseUrl": ".",
|
14
|
+
"paths": {
|
15
|
+
"@/*": ["./src/*"]
|
16
|
+
}
|
17
|
+
},
|
18
|
+
{{#unless (or (eq backend "convex") (eq backend "none"))}}
|
19
|
+
"references": [{
|
20
|
+
"path": "../server"
|
21
|
+
}]
|
22
|
+
{{/unless}}
|
23
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
{{#if (includes addons "pwa")}}
|
2
|
+
import { VitePWA } from "vite-plugin-pwa";
|
3
|
+
{{/if}}
|
4
|
+
import tailwindcss from "@tailwindcss/vite";
|
5
|
+
import { TanStackRouterVite } from "@tanstack/router-plugin/vite";
|
6
|
+
import react from "@vitejs/plugin-react";
|
7
|
+
import path from "node:path";
|
8
|
+
import { defineConfig } from "vite";
|
9
|
+
|
10
|
+
export default defineConfig({
|
11
|
+
plugins: [
|
12
|
+
tailwindcss(),
|
13
|
+
TanStackRouterVite({}),
|
14
|
+
react(),
|
15
|
+
{{#if (includes addons "pwa")}}
|
16
|
+
VitePWA({
|
17
|
+
registerType: "autoUpdate",
|
18
|
+
manifest: {
|
19
|
+
name: "{{projectName}}",
|
20
|
+
short_name: "{{projectName}}",
|
21
|
+
description: "{{projectName}} - PWA Application",
|
22
|
+
theme_color: "#0c0c0c",
|
23
|
+
},
|
24
|
+
pwaAssets: {
|
25
|
+
disabled: false,
|
26
|
+
config: true,
|
27
|
+
},
|
28
|
+
devOptions: {
|
29
|
+
enabled: true,
|
30
|
+
},
|
31
|
+
}),
|
32
|
+
{{/if}}
|
33
|
+
],
|
34
|
+
resolve: {
|
35
|
+
alias: {
|
36
|
+
"@": path.resolve(__dirname, "./src"),
|
37
|
+
},
|
38
|
+
},
|
39
|
+
});
|
@@ -0,0 +1,44 @@
|
|
1
|
+
{
|
2
|
+
"name": "web",
|
3
|
+
"private": true,
|
4
|
+
"type": "module",
|
5
|
+
"scripts": {
|
6
|
+
"build": "vite build",
|
7
|
+
"serve": "vite preview",
|
8
|
+
"dev": "vite dev --port=3001"
|
9
|
+
},
|
10
|
+
"dependencies": {
|
11
|
+
"radix-ui": "^1.4.2",
|
12
|
+
"@tanstack/react-form": "^1.0.5",
|
13
|
+
"@tailwindcss/vite": "^4.1.8",
|
14
|
+
"@tanstack/react-query": "^5.80.6",
|
15
|
+
"@tanstack/react-router": "^1.121.0-alpha.27",
|
16
|
+
"@tanstack/react-router-with-query": "^1.121.0",
|
17
|
+
"@tanstack/react-start": "^1.121.0-alpha.27",
|
18
|
+
"@tanstack/router-plugin": "^1.121.0",
|
19
|
+
"class-variance-authority": "^0.7.1",
|
20
|
+
"clsx": "^2.1.1",
|
21
|
+
"lucide-react": "^0.473.0",
|
22
|
+
"next-themes": "^0.4.6",
|
23
|
+
"react": "19.0.0",
|
24
|
+
"react-dom": "19.0.0",
|
25
|
+
"sonner": "^2.0.3",
|
26
|
+
"tailwindcss": "^4.1.3",
|
27
|
+
"tailwind-merge": "^2.6.0",
|
28
|
+
"tw-animate-css": "^1.2.5",
|
29
|
+
"vite-tsconfig-paths": "^5.1.4",
|
30
|
+
"zod": "^3.25.16"
|
31
|
+
},
|
32
|
+
"devDependencies": {
|
33
|
+
"@tanstack/react-router-devtools": "^1.121.0-alpha.27",
|
34
|
+
"@testing-library/dom": "^10.4.0",
|
35
|
+
"@testing-library/react": "^16.2.0",
|
36
|
+
"@types/react": "^19.0.12",
|
37
|
+
"@types/react-dom": "^19.0.4",
|
38
|
+
"@vitejs/plugin-react": "^4.5.2",
|
39
|
+
"jsdom": "^26.0.0",
|
40
|
+
"typescript": "^5.7.2",
|
41
|
+
"vite": "^6.3.5",
|
42
|
+
"web-vitals": "^4.2.4"
|
43
|
+
}
|
44
|
+
}
|
@@ -0,0 +1,144 @@
|
|
1
|
+
{{#if (eq backend "convex")}}
|
2
|
+
import { createRouter as createTanStackRouter } from "@tanstack/react-router";
|
3
|
+
import { QueryClient } from "@tanstack/react-query";
|
4
|
+
import { routerWithQueryClient } from "@tanstack/react-router-with-query";
|
5
|
+
import { ConvexQueryClient } from "@convex-dev/react-query";
|
6
|
+
import { ConvexProvider } from "convex/react";
|
7
|
+
import { routeTree } from "./routeTree.gen";
|
8
|
+
import Loader from "./components/loader";
|
9
|
+
import "./index.css";
|
10
|
+
{{else}}
|
11
|
+
import { createRouter as createTanStackRouter } from "@tanstack/react-router";
|
12
|
+
import Loader from "./components/loader";
|
13
|
+
import "./index.css";
|
14
|
+
import { routeTree } from "./routeTree.gen";
|
15
|
+
{{#if (eq api "trpc")}}
|
16
|
+
import { QueryCache, QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
17
|
+
import { createTRPCClient, httpBatchLink } from "@trpc/client";
|
18
|
+
import { createTRPCOptionsProxy } from "@trpc/tanstack-react-query";
|
19
|
+
import { toast } from "sonner";
|
20
|
+
import type { AppRouter } from "../../server/src/routers";
|
21
|
+
import { TRPCProvider } from "./utils/trpc";
|
22
|
+
{{else if (eq api "orpc")}}
|
23
|
+
import { QueryClientProvider } from "@tanstack/react-query";
|
24
|
+
import { orpc, queryClient } from "./utils/orpc";
|
25
|
+
{{/if}}
|
26
|
+
{{/if}}
|
27
|
+
|
28
|
+
{{#if (eq backend "convex")}}
|
29
|
+
export function createRouter() {
|
30
|
+
const CONVEX_URL = (import.meta as any).env.VITE_CONVEX_URL!;
|
31
|
+
if (!CONVEX_URL) {
|
32
|
+
console.error("missing envar VITE_CONVEX_URL");
|
33
|
+
}
|
34
|
+
const convexQueryClient = new ConvexQueryClient(CONVEX_URL);
|
35
|
+
|
36
|
+
const queryClient: QueryClient = new QueryClient({
|
37
|
+
defaultOptions: {
|
38
|
+
queries: {
|
39
|
+
queryKeyHashFn: convexQueryClient.hashFn(),
|
40
|
+
queryFn: convexQueryClient.queryFn(),
|
41
|
+
},
|
42
|
+
},
|
43
|
+
});
|
44
|
+
convexQueryClient.connect(queryClient);
|
45
|
+
|
46
|
+
const router = routerWithQueryClient(
|
47
|
+
createTanStackRouter({
|
48
|
+
routeTree,
|
49
|
+
defaultPreload: "intent",
|
50
|
+
defaultPendingComponent: () => <Loader />,
|
51
|
+
defaultNotFoundComponent: () => <div>Not Found</div>,
|
52
|
+
context: { queryClient },
|
53
|
+
Wrap: ({ children }) => (
|
54
|
+
<ConvexProvider client={convexQueryClient.convexClient}>
|
55
|
+
{children}
|
56
|
+
</ConvexProvider>
|
57
|
+
),
|
58
|
+
}),
|
59
|
+
queryClient,
|
60
|
+
);
|
61
|
+
return router;
|
62
|
+
}
|
63
|
+
{{else}}
|
64
|
+
{{#if (eq api "trpc")}}
|
65
|
+
export const queryClient = new QueryClient({
|
66
|
+
queryCache: new QueryCache({
|
67
|
+
onError: (error) => {
|
68
|
+
toast.error(error.message, {
|
69
|
+
action: {
|
70
|
+
label: "retry",
|
71
|
+
onClick: () => {
|
72
|
+
queryClient.invalidateQueries();
|
73
|
+
},
|
74
|
+
},
|
75
|
+
});
|
76
|
+
},
|
77
|
+
}),
|
78
|
+
defaultOptions: { queries: { staleTime: 60 * 1000 } },
|
79
|
+
});
|
80
|
+
|
81
|
+
const trpcClient = createTRPCClient<AppRouter>({
|
82
|
+
links: [
|
83
|
+
httpBatchLink({
|
84
|
+
url: `${import.meta.env.VITE_SERVER_URL}/trpc`,
|
85
|
+
{{#if auth}}
|
86
|
+
fetch(url, options) {
|
87
|
+
return fetch(url, {
|
88
|
+
...options,
|
89
|
+
credentials: "include",
|
90
|
+
});
|
91
|
+
},
|
92
|
+
{{/if}}
|
93
|
+
}),
|
94
|
+
],
|
95
|
+
});
|
96
|
+
|
97
|
+
const trpc = createTRPCOptionsProxy({
|
98
|
+
client: trpcClient,
|
99
|
+
queryClient: queryClient,
|
100
|
+
});
|
101
|
+
{{else if (eq api "orpc")}}
|
102
|
+
{{/if}}
|
103
|
+
|
104
|
+
export const createRouter = () => {
|
105
|
+
const router = createTanStackRouter({
|
106
|
+
routeTree,
|
107
|
+
scrollRestoration: true,
|
108
|
+
defaultPreloadStaleTime: 0,
|
109
|
+
{{#if (eq api "trpc")}}
|
110
|
+
context: { trpc, queryClient },
|
111
|
+
{{else if (eq api "orpc")}}
|
112
|
+
context: { orpc, queryClient },
|
113
|
+
{{else}}
|
114
|
+
context: {},
|
115
|
+
{{/if}}
|
116
|
+
defaultPendingComponent: () => <Loader />,
|
117
|
+
defaultNotFoundComponent: () => <div>Not Found</div>,
|
118
|
+
{{#if (eq api "trpc")}}
|
119
|
+
Wrap: ({ children }) => (
|
120
|
+
<QueryClientProvider client={queryClient}>
|
121
|
+
<TRPCProvider trpcClient={trpcClient} queryClient={queryClient}>
|
122
|
+
{children}
|
123
|
+
</TRPCProvider>
|
124
|
+
</QueryClientProvider>
|
125
|
+
),
|
126
|
+
{{else if (eq api "orpc")}}
|
127
|
+
Wrap: ({ children }) => (
|
128
|
+
<QueryClientProvider client={queryClient}>
|
129
|
+
{children}
|
130
|
+
</QueryClientProvider>
|
131
|
+
),
|
132
|
+
{{else}}
|
133
|
+
Wrap: ({ children }) => <>{children}</>,
|
134
|
+
{{/if}}
|
135
|
+
});
|
136
|
+
return router;
|
137
|
+
};
|
138
|
+
{{/if}}
|
139
|
+
|
140
|
+
declare module "@tanstack/react-router" {
|
141
|
+
interface Register {
|
142
|
+
router: ReturnType<typeof createRouter>;
|
143
|
+
}
|
144
|
+
}
|