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
package/package.json
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
{
|
2
|
+
"name": "tvi-cli",
|
3
|
+
"version": "0.1.4",
|
4
|
+
"description": "A modern CLI tool for scaffolding end-to-end type-safe TypeScript projects with best practices and customizable configurations",
|
5
|
+
"type": "module",
|
6
|
+
"license": "MIT",
|
7
|
+
"author": "Shane Holloman",
|
8
|
+
"bin": {
|
9
|
+
"tvi": "dist/index.js"
|
10
|
+
},
|
11
|
+
"files": [
|
12
|
+
"templates",
|
13
|
+
"dist"
|
14
|
+
],
|
15
|
+
"keywords": [
|
16
|
+
"tvi",
|
17
|
+
"typescript",
|
18
|
+
"boilerplate",
|
19
|
+
"starter",
|
20
|
+
"cli",
|
21
|
+
"turborepo",
|
22
|
+
"trpc",
|
23
|
+
"better-auth",
|
24
|
+
"monorepo",
|
25
|
+
"fullstack",
|
26
|
+
"type-safety",
|
27
|
+
"react",
|
28
|
+
"react-native",
|
29
|
+
"expo",
|
30
|
+
"hono",
|
31
|
+
"elysia",
|
32
|
+
"drizzle",
|
33
|
+
"prisma",
|
34
|
+
"tanstack",
|
35
|
+
"tailwind",
|
36
|
+
"shadcn",
|
37
|
+
"pwa",
|
38
|
+
"tauri",
|
39
|
+
"biome"
|
40
|
+
],
|
41
|
+
"repository": {
|
42
|
+
"type": "git",
|
43
|
+
"url": "git+https://github.com/shaneholloman/tvi.git",
|
44
|
+
"directory": "apps/cli"
|
45
|
+
},
|
46
|
+
"homepage": "https://github.com/shaneholloman/tvi",
|
47
|
+
"scripts": {
|
48
|
+
"build": "tsdown",
|
49
|
+
"dev": "tsdown --watch",
|
50
|
+
"check-types": "tsc --noEmit",
|
51
|
+
"check": "biome check --write .",
|
52
|
+
"test": "vitest run",
|
53
|
+
"prepublishOnly": "npm run build"
|
54
|
+
},
|
55
|
+
"dependencies": {
|
56
|
+
"@clack/prompts": "^0.11.0",
|
57
|
+
"consola": "^3.4.2",
|
58
|
+
"execa": "^9.6.0",
|
59
|
+
"fs-extra": "^11.3.0",
|
60
|
+
"globby": "^14.1.0",
|
61
|
+
"gradient-string": "^3.0.0",
|
62
|
+
"handlebars": "^4.7.8",
|
63
|
+
"jsonc-parser": "^3.3.1",
|
64
|
+
"picocolors": "^1.1.1",
|
65
|
+
"posthog-node": "^5.1.1",
|
66
|
+
"trpc-cli": "^0.9.2",
|
67
|
+
"zod": "^3.25.67"
|
68
|
+
},
|
69
|
+
"devDependencies": {
|
70
|
+
"@types/fs-extra": "^11.0.4",
|
71
|
+
"@types/node": "^24.0.3",
|
72
|
+
"tsdown": "^0.12.8",
|
73
|
+
"typescript": "^5.8.3"
|
74
|
+
}
|
75
|
+
}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
|
3
|
+
"vcs": {
|
4
|
+
"enabled": false,
|
5
|
+
"clientKind": "git",
|
6
|
+
"useIgnoreFile": false
|
7
|
+
},
|
8
|
+
"files": {
|
9
|
+
"ignoreUnknown": false,
|
10
|
+
"includes": [
|
11
|
+
"**",
|
12
|
+
"!**/.next",
|
13
|
+
"!**/dist",
|
14
|
+
"!**/.turbo",
|
15
|
+
"!**/dev-dist",
|
16
|
+
"!**/.zed",
|
17
|
+
"!**/.vscode",
|
18
|
+
"!**/routeTree.gen.ts",
|
19
|
+
"!**/src-tauri",
|
20
|
+
"!**/.nuxt"
|
21
|
+
]
|
22
|
+
},
|
23
|
+
"formatter": {
|
24
|
+
"enabled": true,
|
25
|
+
"indentStyle": "tab"
|
26
|
+
},
|
27
|
+
"assist": { "actions": { "source": { "organizeImports": "on" } } },
|
28
|
+
"linter": {
|
29
|
+
"enabled": true,
|
30
|
+
"rules": {
|
31
|
+
"recommended": true,
|
32
|
+
"correctness": {
|
33
|
+
"useExhaustiveDependencies": "info"
|
34
|
+
},
|
35
|
+
"nursery": {
|
36
|
+
"useSortedClasses": {
|
37
|
+
"level": "warn",
|
38
|
+
"fix": "safe",
|
39
|
+
"options": {
|
40
|
+
"functions": ["clsx", "cva", "cn"]
|
41
|
+
}
|
42
|
+
}
|
43
|
+
},
|
44
|
+
"style": {
|
45
|
+
"noParameterAssign": "error",
|
46
|
+
"useAsConstAssertion": "error",
|
47
|
+
"useDefaultParameterLast": "error",
|
48
|
+
"useEnumInitializers": "error",
|
49
|
+
"useSelfClosingElements": "error",
|
50
|
+
"useSingleVarDeclarator": "error",
|
51
|
+
"noUnusedTemplateLiteral": "error",
|
52
|
+
"useNumberNamespace": "error",
|
53
|
+
"noInferrableTypes": "error",
|
54
|
+
"noUselessElse": "error"
|
55
|
+
}
|
56
|
+
}
|
57
|
+
},
|
58
|
+
"javascript": {
|
59
|
+
"formatter": {
|
60
|
+
"quoteStyle": "double"
|
61
|
+
}
|
62
|
+
}
|
63
|
+
{{#if (or (eq frontend "svelte") (eq frontend "nuxt"))}}
|
64
|
+
,
|
65
|
+
"overrides": [
|
66
|
+
{
|
67
|
+
"includes": ["**/*.svelte", "**/*.vue"],
|
68
|
+
"linter": {
|
69
|
+
"rules": {
|
70
|
+
"style": {
|
71
|
+
"useConst": "off",
|
72
|
+
"useImportType": "off"
|
73
|
+
},
|
74
|
+
"correctness": {
|
75
|
+
"noUnusedVariables": "off",
|
76
|
+
"noUnusedImports": "off"
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
]
|
82
|
+
{{/if}}
|
83
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
lint-staged
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" width="92" height="92"><svg width="92" height="92" viewBox="0 0 92 92" fill="none" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<rect x="8" y="8" width="76" height="76" rx="12" fill="#F5EEFF" stroke="#B79AFF" stroke-width="3"></rect>
|
3
|
+
<text x="46" y="56" text-anchor="middle" font-family="monospace" font-size="40" fill="#8F5BFF">$<tspan dx="0" dy="0">_</tspan></text>
|
4
|
+
</svg><style>@media (prefers-color-scheme: light) { :root { filter: none; } }
|
5
|
+
@media (prefers-color-scheme: dark) { :root { filter: none; } }
|
6
|
+
</style></svg>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"name": "{{projectName}}",
|
3
|
+
"short_name": "{{projectName}}",
|
4
|
+
"icons": [
|
5
|
+
{
|
6
|
+
"src": "/web-app-manifest-192x192.png",
|
7
|
+
"sizes": "192x192",
|
8
|
+
"type": "image/png",
|
9
|
+
"purpose": "maskable"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"src": "/web-app-manifest-512x512.png",
|
13
|
+
"sizes": "512x512",
|
14
|
+
"type": "image/png",
|
15
|
+
"purpose": "maskable"
|
16
|
+
}
|
17
|
+
],
|
18
|
+
"theme_color": "#ffffff",
|
19
|
+
"background_color": "#ffffff",
|
20
|
+
"display": "standalone"
|
21
|
+
}
|
Binary file
|
Binary file
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import type { MetadataRoute } from "next";
|
2
|
+
|
3
|
+
export default function manifest(): MetadataRoute.Manifest {
|
4
|
+
return {
|
5
|
+
name: "{{projectName}}",
|
6
|
+
short_name: "{{projectName}}",
|
7
|
+
description:
|
8
|
+
"my pwa app",
|
9
|
+
start_url: "/new",
|
10
|
+
display: "standalone",
|
11
|
+
background_color: "#ffffff",
|
12
|
+
theme_color: "#000000",
|
13
|
+
icons: [
|
14
|
+
{
|
15
|
+
src: "/favicon/web-app-manifest-192x192.png",
|
16
|
+
sizes: "192x192",
|
17
|
+
type: "image/png",
|
18
|
+
},
|
19
|
+
{
|
20
|
+
src: "/favicon/web-app-manifest-512x512.png",
|
21
|
+
sizes: "512x512",
|
22
|
+
type: "image/png",
|
23
|
+
},
|
24
|
+
],
|
25
|
+
};
|
26
|
+
}
|
Binary file
|
@@ -0,0 +1,43 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://turbo.build/schema.json",
|
3
|
+
"ui": "tui",
|
4
|
+
"tasks": {
|
5
|
+
"build": {
|
6
|
+
"dependsOn": ["^build"],
|
7
|
+
"inputs": ["$TURBO_DEFAULT$", ".env*"],
|
8
|
+
"outputs": ["dist/**"]
|
9
|
+
},
|
10
|
+
"lint": {
|
11
|
+
"dependsOn": ["^lint"]
|
12
|
+
},
|
13
|
+
"check-types": {
|
14
|
+
"dependsOn": ["^check-types"]
|
15
|
+
},
|
16
|
+
"dev": {
|
17
|
+
"cache": false,
|
18
|
+
"persistent": true
|
19
|
+
}{{#if (eq backend "convex")}},
|
20
|
+
"setup": {
|
21
|
+
"cache": false,
|
22
|
+
"persistent": true
|
23
|
+
}
|
24
|
+
{{else}}{{#unless (or (eq database "none") (eq orm "none"))}},
|
25
|
+
"db:push": {
|
26
|
+
"cache": false,
|
27
|
+
"persistent": true
|
28
|
+
},
|
29
|
+
"db:studio": {
|
30
|
+
"cache": false,
|
31
|
+
"persistent": true
|
32
|
+
},
|
33
|
+
"db:migrate": {
|
34
|
+
"cache": false,
|
35
|
+
"persistent": true
|
36
|
+
},
|
37
|
+
"db:generate": {
|
38
|
+
"cache": false,
|
39
|
+
"persistent": true
|
40
|
+
}
|
41
|
+
{{/unless}}{{/if}}
|
42
|
+
}
|
43
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { createORPCClient } from "@orpc/client";
|
2
|
+
import { RPCLink } from "@orpc/client/fetch";
|
3
|
+
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
4
|
+
import type { RouterClient } from "@orpc/server";
|
5
|
+
import { QueryCache, QueryClient } from "@tanstack/react-query";
|
6
|
+
import type { appRouter } from "../../server/src/routers";
|
7
|
+
{{#if auth}}
|
8
|
+
import { authClient } from "@/lib/auth-client";
|
9
|
+
{{/if}}
|
10
|
+
|
11
|
+
export const queryClient = new QueryClient({
|
12
|
+
queryCache: new QueryCache({
|
13
|
+
onError: (error) => {
|
14
|
+
console.log(error)
|
15
|
+
},
|
16
|
+
}),
|
17
|
+
});
|
18
|
+
|
19
|
+
export const link = new RPCLink({
|
20
|
+
url: `${process.env.EXPO_PUBLIC_SERVER_URL}/rpc`,
|
21
|
+
{{#if auth}}
|
22
|
+
headers() {
|
23
|
+
const headers = new Map<string, string>();
|
24
|
+
const cookies = authClient.getCookie();
|
25
|
+
if (cookies) {
|
26
|
+
headers.set("Cookie", cookies);
|
27
|
+
}
|
28
|
+
return Object.fromEntries(headers);
|
29
|
+
},
|
30
|
+
{{/if}}
|
31
|
+
});
|
32
|
+
|
33
|
+
export const client: RouterClient<typeof appRouter> = createORPCClient(link);
|
34
|
+
|
35
|
+
export const orpc = createTanstackQueryUtils(client);
|
@@ -0,0 +1,125 @@
|
|
1
|
+
{{#if (eq backend 'next')}}
|
2
|
+
import type { NextRequest } from "next/server";
|
3
|
+
{{#if auth}}
|
4
|
+
import { auth } from "./auth";
|
5
|
+
{{/if}}
|
6
|
+
|
7
|
+
export async function createContext(req: NextRequest) {
|
8
|
+
{{#if auth}}
|
9
|
+
const session = await auth.api.getSession({
|
10
|
+
headers: req.headers,
|
11
|
+
});
|
12
|
+
return {
|
13
|
+
session,
|
14
|
+
};
|
15
|
+
{{else}}
|
16
|
+
return {}
|
17
|
+
{{/if}}
|
18
|
+
}
|
19
|
+
|
20
|
+
{{else if (eq backend 'hono')}}
|
21
|
+
import type { Context as HonoContext } from "hono";
|
22
|
+
{{#if auth}}
|
23
|
+
import { auth } from "./auth";
|
24
|
+
{{/if}}
|
25
|
+
|
26
|
+
export type CreateContextOptions = {
|
27
|
+
context: HonoContext;
|
28
|
+
};
|
29
|
+
|
30
|
+
export async function createContext({ context }: CreateContextOptions) {
|
31
|
+
{{#if auth}}
|
32
|
+
const session = await auth.api.getSession({
|
33
|
+
headers: context.req.raw.headers,
|
34
|
+
});
|
35
|
+
return {
|
36
|
+
session,
|
37
|
+
};
|
38
|
+
{{else}}
|
39
|
+
// No auth configured
|
40
|
+
return {
|
41
|
+
session: null,
|
42
|
+
};
|
43
|
+
{{/if}}
|
44
|
+
}
|
45
|
+
|
46
|
+
{{else if (eq backend 'elysia')}}
|
47
|
+
import type { Context as ElysiaContext } from "elysia";
|
48
|
+
{{#if auth}}
|
49
|
+
import { auth } from "./auth";
|
50
|
+
{{/if}}
|
51
|
+
|
52
|
+
export type CreateContextOptions = {
|
53
|
+
context: ElysiaContext;
|
54
|
+
};
|
55
|
+
|
56
|
+
export async function createContext({ context }: CreateContextOptions) {
|
57
|
+
{{#if auth}}
|
58
|
+
const session = await auth.api.getSession({
|
59
|
+
headers: context.request.headers,
|
60
|
+
});
|
61
|
+
return {
|
62
|
+
session,
|
63
|
+
};
|
64
|
+
{{else}}
|
65
|
+
// No auth configured
|
66
|
+
return {
|
67
|
+
session: null,
|
68
|
+
};
|
69
|
+
{{/if}}
|
70
|
+
}
|
71
|
+
|
72
|
+
{{else if (eq backend 'express')}}
|
73
|
+
{{#if auth}}
|
74
|
+
import { fromNodeHeaders } from "better-auth/node";
|
75
|
+
import { auth } from "./auth";
|
76
|
+
{{/if}}
|
77
|
+
|
78
|
+
export async function createContext(opts: any) {
|
79
|
+
{{#if auth}}
|
80
|
+
const session = await auth.api.getSession({
|
81
|
+
headers: fromNodeHeaders(opts.req.headers),
|
82
|
+
});
|
83
|
+
return {
|
84
|
+
session,
|
85
|
+
};
|
86
|
+
{{else}}
|
87
|
+
// No auth configured
|
88
|
+
return {
|
89
|
+
session: null,
|
90
|
+
};
|
91
|
+
{{/if}}
|
92
|
+
}
|
93
|
+
|
94
|
+
{{else if (eq backend 'fastify')}}
|
95
|
+
import type { IncomingHttpHeaders } from "node:http";
|
96
|
+
{{#if auth}}
|
97
|
+
import { fromNodeHeaders } from "better-auth/node";
|
98
|
+
import { auth } from "./auth";
|
99
|
+
{{/if}}
|
100
|
+
|
101
|
+
export async function createContext(req: IncomingHttpHeaders) {
|
102
|
+
{{#if auth}}
|
103
|
+
const session = await auth.api.getSession({
|
104
|
+
headers: fromNodeHeaders(req),
|
105
|
+
});
|
106
|
+
return {
|
107
|
+
session,
|
108
|
+
};
|
109
|
+
{{else}}
|
110
|
+
// No auth configured
|
111
|
+
return {
|
112
|
+
session: null,
|
113
|
+
};
|
114
|
+
{{/if}}
|
115
|
+
}
|
116
|
+
|
117
|
+
{{else}}
|
118
|
+
export async function createContext() {
|
119
|
+
return {
|
120
|
+
session: null,
|
121
|
+
};
|
122
|
+
}
|
123
|
+
{{/if}}
|
124
|
+
|
125
|
+
export type Context = Awaited<ReturnType<typeof createContext>>;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { ORPCError, os } from "@orpc/server";
|
2
|
+
import type { Context } from "./context";
|
3
|
+
|
4
|
+
export const o = os.$context<Context>();
|
5
|
+
|
6
|
+
export const publicProcedure = o;
|
7
|
+
|
8
|
+
{{#if auth}}
|
9
|
+
const requireAuth = o.middleware(async ({ context, next }) => {
|
10
|
+
if (!context.session?.user) {
|
11
|
+
throw new ORPCError("UNAUTHORIZED");
|
12
|
+
}
|
13
|
+
return next({
|
14
|
+
context: {
|
15
|
+
session: context.session,
|
16
|
+
},
|
17
|
+
});
|
18
|
+
});
|
19
|
+
|
20
|
+
export const protectedProcedure = publicProcedure.use(requireAuth);
|
21
|
+
{{/if}}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
{{#if auth}}
|
2
|
+
import { createContext } from '@/lib/context'
|
3
|
+
{{/if}}
|
4
|
+
import { appRouter } from '@/routers'
|
5
|
+
import { RPCHandler } from '@orpc/server/fetch'
|
6
|
+
import { NextRequest } from 'next/server'
|
7
|
+
|
8
|
+
const handler = new RPCHandler(appRouter)
|
9
|
+
|
10
|
+
async function handleRequest(req: NextRequest) {
|
11
|
+
const { response } = await handler.handle(req, {
|
12
|
+
prefix: '/rpc',
|
13
|
+
context: {{#if auth}}await createContext(req){{else}}{}{{/if}},
|
14
|
+
})
|
15
|
+
|
16
|
+
return response ?? new Response('Not found', { status: 404 })
|
17
|
+
}
|
18
|
+
|
19
|
+
export const GET = handleRequest
|
20
|
+
export const POST = handleRequest
|
21
|
+
export const PUT = handleRequest
|
22
|
+
export const PATCH = handleRequest
|
23
|
+
export const DELETE = handleRequest
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { defineNuxtPlugin, useRuntimeConfig } from '#app'
|
2
|
+
import type { RouterClient } from '@orpc/server'
|
3
|
+
import type { appRouter } from "../../../server/src/routers/index";
|
4
|
+
import { createORPCClient } from '@orpc/client'
|
5
|
+
import { RPCLink } from '@orpc/client/fetch'
|
6
|
+
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
7
|
+
|
8
|
+
export default defineNuxtPlugin(() => {
|
9
|
+
const config = useRuntimeConfig()
|
10
|
+
const serverUrl = config.public.serverURL
|
11
|
+
|
12
|
+
const rpcUrl = `${serverUrl}/rpc`;
|
13
|
+
|
14
|
+
const rpcLink = new RPCLink({
|
15
|
+
url: rpcUrl,
|
16
|
+
{{#if auth}}
|
17
|
+
fetch(url, options) {
|
18
|
+
return fetch(url, {
|
19
|
+
...options,
|
20
|
+
credentials: "include",
|
21
|
+
});
|
22
|
+
},
|
23
|
+
{{/if}}
|
24
|
+
})
|
25
|
+
|
26
|
+
|
27
|
+
const client: RouterClient<typeof appRouter> = createORPCClient(rpcLink)
|
28
|
+
const orpcUtils = createTanstackQueryUtils(client)
|
29
|
+
|
30
|
+
return {
|
31
|
+
provide: {
|
32
|
+
orpc: orpcUtils
|
33
|
+
}
|
34
|
+
}
|
35
|
+
})
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import { createORPCClient } from "@orpc/client";
|
2
|
+
import { RPCLink } from "@orpc/client/fetch";
|
3
|
+
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
4
|
+
import { QueryCache, QueryClient } from "@tanstack/react-query";
|
5
|
+
import { toast } from "sonner";
|
6
|
+
import type { appRouter } from "../../../server/src/routers/index";
|
7
|
+
import type { RouterClient } from "@orpc/server";
|
8
|
+
|
9
|
+
export const queryClient = new QueryClient({
|
10
|
+
queryCache: new QueryCache({
|
11
|
+
onError: (error) => {
|
12
|
+
toast.error(`Error: ${error.message}`, {
|
13
|
+
action: {
|
14
|
+
label: "retry",
|
15
|
+
onClick: () => {
|
16
|
+
queryClient.invalidateQueries();
|
17
|
+
},
|
18
|
+
},
|
19
|
+
});
|
20
|
+
},
|
21
|
+
}),
|
22
|
+
});
|
23
|
+
|
24
|
+
export const link = new RPCLink({
|
25
|
+
{{#if (includes frontend "next")}}
|
26
|
+
url: `${process.env.NEXT_PUBLIC_SERVER_URL}/rpc`,
|
27
|
+
{{else}}
|
28
|
+
url: `${import.meta.env.VITE_SERVER_URL}/rpc`,
|
29
|
+
{{/if}}
|
30
|
+
{{#if auth}}
|
31
|
+
fetch(url, options) {
|
32
|
+
return fetch(url, {
|
33
|
+
...options,
|
34
|
+
credentials: "include",
|
35
|
+
});
|
36
|
+
},
|
37
|
+
{{/if}}
|
38
|
+
});
|
39
|
+
|
40
|
+
export const client: RouterClient<typeof appRouter> = createORPCClient(link)
|
41
|
+
|
42
|
+
export const orpc = createTanstackQueryUtils(client)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { createORPCClient } from "@orpc/client";
|
2
|
+
import { RPCLink } from "@orpc/client/fetch";
|
3
|
+
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
4
|
+
import { QueryCache, QueryClient } from "@tanstack/solid-query";
|
5
|
+
import type { appRouter } from "../../../server/src/routers/index";
|
6
|
+
import type { RouterClient } from "@orpc/server";
|
7
|
+
|
8
|
+
export const queryClient = new QueryClient({
|
9
|
+
queryCache: new QueryCache({
|
10
|
+
onError: (error) => {
|
11
|
+
console.error(`Error: ${error.message}`);
|
12
|
+
},
|
13
|
+
}),
|
14
|
+
});
|
15
|
+
|
16
|
+
export const link = new RPCLink({
|
17
|
+
url: `${import.meta.env.VITE_SERVER_URL}/rpc`,
|
18
|
+
{{#if auth}}
|
19
|
+
fetch(url, options) {
|
20
|
+
return fetch(url, {
|
21
|
+
...options,
|
22
|
+
credentials: "include",
|
23
|
+
});
|
24
|
+
},
|
25
|
+
{{/if}}
|
26
|
+
});
|
27
|
+
|
28
|
+
export const client: RouterClient<typeof appRouter> = createORPCClient(link);
|
29
|
+
|
30
|
+
export const orpc = createTanstackQueryUtils(client);
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { PUBLIC_SERVER_URL } from "$env/static/public";
|
2
|
+
import { createORPCClient } from "@orpc/client";
|
3
|
+
import { RPCLink } from "@orpc/client/fetch";
|
4
|
+
import type { RouterClient } from "@orpc/server";
|
5
|
+
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
6
|
+
import { QueryCache, QueryClient } from "@tanstack/svelte-query";
|
7
|
+
import type { appRouter } from "../../../server/src/routers/index";
|
8
|
+
|
9
|
+
export const queryClient = new QueryClient({
|
10
|
+
queryCache: new QueryCache({
|
11
|
+
onError: (error) => {
|
12
|
+
console.error(`Error: ${error.message}`);
|
13
|
+
},
|
14
|
+
}),
|
15
|
+
});
|
16
|
+
|
17
|
+
export const link = new RPCLink({
|
18
|
+
url: `${PUBLIC_SERVER_URL}/rpc`,
|
19
|
+
{{#if auth}}
|
20
|
+
fetch(url, options) {
|
21
|
+
return fetch(url, {
|
22
|
+
...options,
|
23
|
+
credentials: "include",
|
24
|
+
});
|
25
|
+
},
|
26
|
+
{{/if}}
|
27
|
+
});
|
28
|
+
|
29
|
+
export const client: RouterClient<typeof appRouter> = createORPCClient(link);
|
30
|
+
|
31
|
+
export const orpc = createTanstackQueryUtils(client);
|
@@ -0,0 +1,32 @@
|
|
1
|
+
{{#if auth}}
|
2
|
+
import { authClient } from "@/lib/auth-client";
|
3
|
+
{{/if}}
|
4
|
+
import { QueryClient } from "@tanstack/react-query";
|
5
|
+
import { createTRPCClient, httpBatchLink } from "@trpc/client";
|
6
|
+
import { createTRPCOptionsProxy } from "@trpc/tanstack-react-query";
|
7
|
+
import type { AppRouter } from "../../server/src/routers";
|
8
|
+
|
9
|
+
export const queryClient = new QueryClient();
|
10
|
+
|
11
|
+
const trpcClient = createTRPCClient<AppRouter>({
|
12
|
+
links: [
|
13
|
+
httpBatchLink({
|
14
|
+
url: `${process.env.EXPO_PUBLIC_SERVER_URL}/trpc`,
|
15
|
+
{{#if auth}}
|
16
|
+
headers() {
|
17
|
+
const headers = new Map<string, string>();
|
18
|
+
const cookies = authClient.getCookie();
|
19
|
+
if (cookies) {
|
20
|
+
headers.set("Cookie", cookies);
|
21
|
+
}
|
22
|
+
return Object.fromEntries(headers);
|
23
|
+
},
|
24
|
+
{{/if}}
|
25
|
+
}),
|
26
|
+
],
|
27
|
+
});
|
28
|
+
|
29
|
+
export const trpc = createTRPCOptionsProxy<AppRouter>({
|
30
|
+
client: trpcClient,
|
31
|
+
queryClient,
|
32
|
+
});
|