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,158 @@
|
|
1
|
+
import { authClient } from "@/lib/auth-client";
|
2
|
+
import { createForm } from "@tanstack/solid-form";
|
3
|
+
import { useNavigate } from "@tanstack/solid-router";
|
4
|
+
import z from "zod/v4";
|
5
|
+
import { For } from "solid-js";
|
6
|
+
|
7
|
+
export default function SignUpForm({
|
8
|
+
onSwitchToSignIn,
|
9
|
+
}: {
|
10
|
+
onSwitchToSignIn: () => void;
|
11
|
+
}) {
|
12
|
+
const navigate = useNavigate({
|
13
|
+
from: "/",
|
14
|
+
});
|
15
|
+
|
16
|
+
const form = createForm(() => ({
|
17
|
+
defaultValues: {
|
18
|
+
email: "",
|
19
|
+
password: "",
|
20
|
+
name: "",
|
21
|
+
},
|
22
|
+
onSubmit: async ({ value }) => {
|
23
|
+
await authClient.signUp.email(
|
24
|
+
{
|
25
|
+
email: value.email,
|
26
|
+
password: value.password,
|
27
|
+
name: value.name,
|
28
|
+
},
|
29
|
+
{
|
30
|
+
onSuccess: () => {
|
31
|
+
navigate({
|
32
|
+
to: "/dashboard",
|
33
|
+
});
|
34
|
+
console.log("Sign up successful");
|
35
|
+
},
|
36
|
+
onError: (error) => {
|
37
|
+
console.error(error.error.message);
|
38
|
+
},
|
39
|
+
},
|
40
|
+
);
|
41
|
+
},
|
42
|
+
validators: {
|
43
|
+
onSubmit: z.object({
|
44
|
+
name: z.string().min(2, "Name must be at least 2 characters"),
|
45
|
+
email: z.email("Invalid email address"),
|
46
|
+
password: z.string().min(8, "Password must be at least 8 characters"),
|
47
|
+
}),
|
48
|
+
},
|
49
|
+
}));
|
50
|
+
|
51
|
+
return (
|
52
|
+
<div class="mx-auto w-full mt-10 max-w-md p-6">
|
53
|
+
<h1 class="mb-6 text-center text-3xl font-bold">Create Account</h1>
|
54
|
+
|
55
|
+
<form
|
56
|
+
onSubmit={(e) => {
|
57
|
+
e.preventDefault();
|
58
|
+
e.stopPropagation();
|
59
|
+
void form.handleSubmit();
|
60
|
+
}}
|
61
|
+
class="space-y-4"
|
62
|
+
>
|
63
|
+
<div>
|
64
|
+
<form.Field name="name">
|
65
|
+
{(field) => (
|
66
|
+
<div class="space-y-2">
|
67
|
+
<label for={field().name}>Name</label>
|
68
|
+
<input
|
69
|
+
id={field().name}
|
70
|
+
name={field().name}
|
71
|
+
value={field().state.value}
|
72
|
+
onBlur={field().handleBlur}
|
73
|
+
onInput={(e) => field().handleChange(e.currentTarget.value)}
|
74
|
+
class="w-full rounded border p-2"
|
75
|
+
/>
|
76
|
+
<For each={field().state.meta.errors}>
|
77
|
+
{(error) => (
|
78
|
+
<p class="text-sm text-red-600">{error?.message}</p>
|
79
|
+
)}
|
80
|
+
</For>
|
81
|
+
</div>
|
82
|
+
)}
|
83
|
+
</form.Field>
|
84
|
+
</div>
|
85
|
+
|
86
|
+
<div>
|
87
|
+
<form.Field name="email">
|
88
|
+
{(field) => (
|
89
|
+
<div class="space-y-2">
|
90
|
+
<label for={field().name}>Email</label>
|
91
|
+
<input
|
92
|
+
id={field().name}
|
93
|
+
name={field().name}
|
94
|
+
type="email"
|
95
|
+
value={field().state.value}
|
96
|
+
onBlur={field().handleBlur}
|
97
|
+
onInput={(e) => field().handleChange(e.currentTarget.value)}
|
98
|
+
class="w-full rounded border p-2"
|
99
|
+
/>
|
100
|
+
<For each={field().state.meta.errors}>
|
101
|
+
{(error) => (
|
102
|
+
<p class="text-sm text-red-600">{error?.message}</p>
|
103
|
+
)}
|
104
|
+
</For>
|
105
|
+
</div>
|
106
|
+
)}
|
107
|
+
</form.Field>
|
108
|
+
</div>
|
109
|
+
|
110
|
+
<div>
|
111
|
+
<form.Field name="password">
|
112
|
+
{(field) => (
|
113
|
+
<div class="space-y-2">
|
114
|
+
<label for={field().name}>Password</label>
|
115
|
+
<input
|
116
|
+
id={field().name}
|
117
|
+
name={field().name}
|
118
|
+
type="password"
|
119
|
+
value={field().state.value}
|
120
|
+
onBlur={field().handleBlur}
|
121
|
+
onInput={(e) => field().handleChange(e.currentTarget.value)}
|
122
|
+
class="w-full rounded border p-2"
|
123
|
+
/>
|
124
|
+
<For each={field().state.meta.errors}>
|
125
|
+
{(error) => (
|
126
|
+
<p class="text-sm text-red-600">{error?.message}</p>
|
127
|
+
)}
|
128
|
+
</For>
|
129
|
+
</div>
|
130
|
+
)}
|
131
|
+
</form.Field>
|
132
|
+
</div>
|
133
|
+
|
134
|
+
<form.Subscribe>
|
135
|
+
{(state) => (
|
136
|
+
<button
|
137
|
+
type="submit"
|
138
|
+
class="w-full rounded bg-indigo-600 p-2 text-white hover:bg-indigo-700 disabled:opacity-50"
|
139
|
+
disabled={!state().canSubmit || state().isSubmitting}
|
140
|
+
>
|
141
|
+
{state().isSubmitting ? "Submitting..." : "Sign Up"}
|
142
|
+
</button>
|
143
|
+
)}
|
144
|
+
</form.Subscribe>
|
145
|
+
</form>
|
146
|
+
|
147
|
+
<div class="mt-4 text-center">
|
148
|
+
<button
|
149
|
+
type="button"
|
150
|
+
onClick={onSwitchToSignIn}
|
151
|
+
class="text-sm text-indigo-600 hover:text-indigo-800 hover:underline"
|
152
|
+
>
|
153
|
+
Already have an account? Sign In
|
154
|
+
</button>
|
155
|
+
</div>
|
156
|
+
</div>
|
157
|
+
);
|
158
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import { authClient } from "@/lib/auth-client";
|
2
|
+
import { useNavigate, Link } from "@tanstack/solid-router";
|
3
|
+
import { createSignal, Show } from "solid-js";
|
4
|
+
|
5
|
+
export default function UserMenu() {
|
6
|
+
const navigate = useNavigate();
|
7
|
+
const session = authClient.useSession();
|
8
|
+
const [isMenuOpen, setIsMenuOpen] = createSignal(false);
|
9
|
+
|
10
|
+
return (
|
11
|
+
<div class="relative inline-block text-left">
|
12
|
+
<Show when={session().isPending}>
|
13
|
+
<div class="h-9 w-24 animate-pulse rounded" />
|
14
|
+
</Show>
|
15
|
+
|
16
|
+
<Show when={!session().isPending && !session().data}>
|
17
|
+
<Link to="/login" class="inline-block border rounded px-4 text-sm">
|
18
|
+
Sign In
|
19
|
+
</Link>
|
20
|
+
</Show>
|
21
|
+
|
22
|
+
<Show when={!session().isPending && session().data}>
|
23
|
+
<button
|
24
|
+
type="button"
|
25
|
+
class="inline-block border rounded px-4 text-sm"
|
26
|
+
onClick={() => setIsMenuOpen(!isMenuOpen())}
|
27
|
+
>
|
28
|
+
{session().data?.user.name}
|
29
|
+
</button>
|
30
|
+
|
31
|
+
<Show when={isMenuOpen()}>
|
32
|
+
<div class="absolute right-0 mt-2 w-56 rounded p-1 shadow-sm">
|
33
|
+
<div class="px-4 text-sm">{session().data?.user.email}</div>
|
34
|
+
<button
|
35
|
+
type="button"
|
36
|
+
class="mt-1 w-full border rounded px-4 text-center text-sm"
|
37
|
+
onClick={() => {
|
38
|
+
setIsMenuOpen(false);
|
39
|
+
authClient.signOut({
|
40
|
+
fetchOptions: {
|
41
|
+
onSuccess: () => {
|
42
|
+
navigate({ to: "/" });
|
43
|
+
},
|
44
|
+
},
|
45
|
+
});
|
46
|
+
}}
|
47
|
+
>
|
48
|
+
Sign Out
|
49
|
+
</button>
|
50
|
+
</div>
|
51
|
+
</Show>
|
52
|
+
</Show>
|
53
|
+
</div>
|
54
|
+
);
|
55
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { authClient } from "@/lib/auth-client";
|
2
|
+
import { orpc } from "@/utils/orpc";
|
3
|
+
import { useQuery } from "@tanstack/solid-query";
|
4
|
+
import { createFileRoute } from "@tanstack/solid-router";
|
5
|
+
import { createEffect, Show } from "solid-js";
|
6
|
+
|
7
|
+
export const Route = createFileRoute("/dashboard")({
|
8
|
+
component: RouteComponent,
|
9
|
+
});
|
10
|
+
|
11
|
+
function RouteComponent() {
|
12
|
+
const session = authClient.useSession();
|
13
|
+
const navigate = Route.useNavigate();
|
14
|
+
|
15
|
+
const privateData = useQuery(() => orpc.privateData.queryOptions());
|
16
|
+
|
17
|
+
createEffect(() => {
|
18
|
+
if (!session().data && !session().isPending) {
|
19
|
+
navigate({
|
20
|
+
to: "/login",
|
21
|
+
});
|
22
|
+
}
|
23
|
+
});
|
24
|
+
|
25
|
+
return (
|
26
|
+
<div>
|
27
|
+
<Show when={session().isPending}>
|
28
|
+
<div>Loading...</div>
|
29
|
+
</Show>
|
30
|
+
|
31
|
+
<Show when={!session().isPending && session().data}>
|
32
|
+
<h1>Dashboard</h1>
|
33
|
+
<p>Welcome {session().data?.user.name}</p>
|
34
|
+
<p>privateData: {privateData.data?.message}</p>
|
35
|
+
</Show>
|
36
|
+
</div>
|
37
|
+
);
|
38
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import SignInForm from "@/components/sign-in-form";
|
2
|
+
import SignUpForm from "@/components/sign-up-form";
|
3
|
+
import { createFileRoute } from "@tanstack/solid-router";
|
4
|
+
import { createSignal, Match, Switch } from "solid-js";
|
5
|
+
|
6
|
+
export const Route = createFileRoute("/login")({
|
7
|
+
component: RouteComponent,
|
8
|
+
});
|
9
|
+
|
10
|
+
function RouteComponent() {
|
11
|
+
const [showSignIn, setShowSignIn] = createSignal(false);
|
12
|
+
|
13
|
+
return (
|
14
|
+
<Switch>
|
15
|
+
<Match when={showSignIn()}>
|
16
|
+
<SignInForm onSwitchToSignUp={() => setShowSignIn(false)} />
|
17
|
+
</Match>
|
18
|
+
<Match when={!showSignIn()}>
|
19
|
+
<SignUpForm onSwitchToSignIn={() => setShowSignIn(true)} />
|
20
|
+
</Match>
|
21
|
+
</Switch>
|
22
|
+
);
|
23
|
+
}
|
@@ -0,0 +1,108 @@
|
|
1
|
+
<script lang="ts">
|
2
|
+
import { createForm } from '@tanstack/svelte-form';
|
3
|
+
import z from 'zod/v4';
|
4
|
+
import { authClient } from '$lib/auth-client';
|
5
|
+
import { goto } from '$app/navigation';
|
6
|
+
|
7
|
+
let { switchToSignUp } = $props<{ switchToSignUp: () => void }>();
|
8
|
+
|
9
|
+
const validationSchema = z.object({
|
10
|
+
email: z.email('Invalid email address'),
|
11
|
+
password: z.string().min(1, 'Password is required'),
|
12
|
+
});
|
13
|
+
|
14
|
+
const form = createForm(() => ({
|
15
|
+
defaultValues: { email: '', password: '' },
|
16
|
+
onSubmit: async ({ value }) => {
|
17
|
+
await authClient.signIn.email(
|
18
|
+
{ email: value.email, password: value.password },
|
19
|
+
{
|
20
|
+
onSuccess: () => goto('/dashboard'),
|
21
|
+
onError: (error) => {
|
22
|
+
console.log(error.error.message || 'Sign in failed. Please try again.');
|
23
|
+
},
|
24
|
+
}
|
25
|
+
);
|
26
|
+
|
27
|
+
},
|
28
|
+
validators: {
|
29
|
+
onSubmit: validationSchema,
|
30
|
+
},
|
31
|
+
}));
|
32
|
+
</script>
|
33
|
+
|
34
|
+
<div class="mx-auto mt-10 w-full max-w-md p-6">
|
35
|
+
<h1 class="mb-6 text-center font-bold text-3xl">Welcome Back</h1>
|
36
|
+
|
37
|
+
<form
|
38
|
+
class="space-y-4"
|
39
|
+
onsubmit={(e) => {
|
40
|
+
e.preventDefault();
|
41
|
+
e.stopPropagation();
|
42
|
+
form.handleSubmit();
|
43
|
+
}}
|
44
|
+
>
|
45
|
+
<form.Field name="email">
|
46
|
+
{#snippet children(field)}
|
47
|
+
<div class="space-y-1">
|
48
|
+
<label for={field.name}>Email</label>
|
49
|
+
<input
|
50
|
+
id={field.name}
|
51
|
+
name={field.name}
|
52
|
+
type="email"
|
53
|
+
class="w-full border"
|
54
|
+
onblur={field.handleBlur}
|
55
|
+
value={field.state.value}
|
56
|
+
oninput={(e: Event) => {
|
57
|
+
const target = e.target as HTMLInputElement
|
58
|
+
field.handleChange(target.value)
|
59
|
+
}} />
|
60
|
+
{#if field.state.meta.isTouched}
|
61
|
+
{#each field.state.meta.errors as error}
|
62
|
+
<p class="text-sm text-red-500" role="alert">{error}</p>
|
63
|
+
{/each}
|
64
|
+
{/if}
|
65
|
+
</div>
|
66
|
+
{/snippet}
|
67
|
+
</form.Field>
|
68
|
+
|
69
|
+
<form.Field name="password">
|
70
|
+
{#snippet children(field)}
|
71
|
+
<div class="space-y-1">
|
72
|
+
<label for={field.name}>Password</label>
|
73
|
+
<input
|
74
|
+
id={field.name}
|
75
|
+
name={field.name}
|
76
|
+
type="password"
|
77
|
+
class="w-full border"
|
78
|
+
onblur={field.handleBlur}
|
79
|
+
value={field.state.value}
|
80
|
+
oninput={(e: Event) => {
|
81
|
+
const target = e.target as HTMLInputElement
|
82
|
+
field.handleChange(target.value)
|
83
|
+
}}
|
84
|
+
/>
|
85
|
+
{#if field.state.meta.isTouched}
|
86
|
+
{#each field.state.meta.errors as error}
|
87
|
+
<p class="text-sm text-red-500" role="alert">{error}</p>
|
88
|
+
{/each}
|
89
|
+
{/if}
|
90
|
+
</div>
|
91
|
+
{/snippet}
|
92
|
+
</form.Field>
|
93
|
+
|
94
|
+
<form.Subscribe selector={(state) => ({ canSubmit: state.canSubmit, isSubmitting: state.isSubmitting })}>
|
95
|
+
{#snippet children(state)}
|
96
|
+
<button type="submit" class="w-full" disabled={!state.canSubmit || state.isSubmitting}>
|
97
|
+
{state.isSubmitting ? 'Submitting...' : 'Sign In'}
|
98
|
+
</button>
|
99
|
+
{/snippet}
|
100
|
+
</form.Subscribe>
|
101
|
+
</form>
|
102
|
+
|
103
|
+
<div class="mt-4 text-center">
|
104
|
+
<button type="button" class="text-indigo-600 hover:text-indigo-800" onclick={switchToSignUp}>
|
105
|
+
Need an account? Sign Up
|
106
|
+
</button>
|
107
|
+
</div>
|
108
|
+
</div>
|
@@ -0,0 +1,142 @@
|
|
1
|
+
<script lang="ts">
|
2
|
+
import { createForm } from '@tanstack/svelte-form';
|
3
|
+
import z from 'zod/v4';
|
4
|
+
import { authClient } from '$lib/auth-client';
|
5
|
+
import { goto } from '$app/navigation';
|
6
|
+
|
7
|
+
let { switchToSignIn } = $props<{ switchToSignIn: () => void }>();
|
8
|
+
|
9
|
+
const validationSchema = z.object({
|
10
|
+
name: z.string().min(2, 'Name must be at least 2 characters'),
|
11
|
+
email: z.email('Invalid email address'),
|
12
|
+
password: z.string().min(8, 'Password must be at least 8 characters'),
|
13
|
+
});
|
14
|
+
|
15
|
+
|
16
|
+
const form = createForm(() => ({
|
17
|
+
defaultValues: { name: '', email: '', password: '' },
|
18
|
+
onSubmit: async ({ value }) => {
|
19
|
+
await authClient.signUp.email(
|
20
|
+
{
|
21
|
+
email: value.email,
|
22
|
+
password: value.password,
|
23
|
+
name: value.name,
|
24
|
+
},
|
25
|
+
{
|
26
|
+
onSuccess: () => {
|
27
|
+
goto('/dashboard');
|
28
|
+
},
|
29
|
+
onError: (error) => {
|
30
|
+
console.log(error.error.message || 'Sign up failed. Please try again.');
|
31
|
+
},
|
32
|
+
}
|
33
|
+
);
|
34
|
+
|
35
|
+
},
|
36
|
+
validators: {
|
37
|
+
onSubmit: validationSchema,
|
38
|
+
},
|
39
|
+
}));
|
40
|
+
</script>
|
41
|
+
|
42
|
+
<div class="mx-auto mt-10 w-full max-w-md p-6">
|
43
|
+
<h1 class="mb-6 text-center font-bold text-3xl">Create Account</h1>
|
44
|
+
|
45
|
+
<form
|
46
|
+
id="form"
|
47
|
+
class="space-y-4"
|
48
|
+
onsubmit={(e) => {
|
49
|
+
e.preventDefault();
|
50
|
+
e.stopPropagation();
|
51
|
+
form.handleSubmit();
|
52
|
+
}}
|
53
|
+
>
|
54
|
+
<form.Field name="name">
|
55
|
+
{#snippet children(field)}
|
56
|
+
<div class="space-y-1">
|
57
|
+
<label for={field.name}>Name</label>
|
58
|
+
<input
|
59
|
+
id={field.name}
|
60
|
+
name={field.name}
|
61
|
+
class="w-full border"
|
62
|
+
onblur={field.handleBlur}
|
63
|
+
value={field.state.value}
|
64
|
+
oninput={(e: Event) => {
|
65
|
+
const target = e.target as HTMLInputElement
|
66
|
+
field.handleChange(target.value)
|
67
|
+
}}
|
68
|
+
/>
|
69
|
+
{#if field.state.meta.isTouched}
|
70
|
+
{#each field.state.meta.errors as error}
|
71
|
+
<p class="text-sm text-red-500" role="alert">{error}</p>
|
72
|
+
{/each}
|
73
|
+
{/if}
|
74
|
+
</div>
|
75
|
+
{/snippet}
|
76
|
+
</form.Field>
|
77
|
+
|
78
|
+
<form.Field name="email">
|
79
|
+
{#snippet children(field)}
|
80
|
+
<div class="space-y-1">
|
81
|
+
<label for={field.name}>Email</label>
|
82
|
+
<input
|
83
|
+
id={field.name}
|
84
|
+
name={field.name}
|
85
|
+
type="email"
|
86
|
+
class="w-full border"
|
87
|
+
onblur={field.handleBlur}
|
88
|
+
value={field.state.value}
|
89
|
+
oninput={(e: Event) => {
|
90
|
+
const target = e.target as HTMLInputElement
|
91
|
+
field.handleChange(target.value)
|
92
|
+
}}
|
93
|
+
/>
|
94
|
+
{#if field.state.meta.isTouched}
|
95
|
+
{#each field.state.meta.errors as error}
|
96
|
+
<p class="text-sm text-red-500" role="alert">{error}</p>
|
97
|
+
{/each}
|
98
|
+
{/if}
|
99
|
+
</div>
|
100
|
+
{/snippet}
|
101
|
+
</form.Field>
|
102
|
+
|
103
|
+
<form.Field name="password">
|
104
|
+
{#snippet children(field)}
|
105
|
+
<div class="space-y-1">
|
106
|
+
<label for={field.name}>Password</label>
|
107
|
+
<input
|
108
|
+
id={field.name}
|
109
|
+
name={field.name}
|
110
|
+
type="password"
|
111
|
+
class="w-full border"
|
112
|
+
onblur={field.handleBlur}
|
113
|
+
value={field.state.value}
|
114
|
+
oninput={(e: Event) => {
|
115
|
+
const target = e.target as HTMLInputElement
|
116
|
+
field.handleChange(target.value)
|
117
|
+
}}
|
118
|
+
/>
|
119
|
+
{#if field.state.meta.errors}
|
120
|
+
{#each field.state.meta.errors as error}
|
121
|
+
<p class="text-sm text-red-500" role="alert">{error}</p>
|
122
|
+
{/each}
|
123
|
+
{/if}
|
124
|
+
</div>
|
125
|
+
{/snippet}
|
126
|
+
</form.Field>
|
127
|
+
|
128
|
+
<form.Subscribe selector={(state) => ({ canSubmit: state.canSubmit, isSubmitting: state.isSubmitting })}>
|
129
|
+
{#snippet children(state)}
|
130
|
+
<button type="submit" class="w-full" disabled={!state.canSubmit || state.isSubmitting}>
|
131
|
+
{state.isSubmitting ? 'Submitting...' : 'Sign Up'}
|
132
|
+
</button>
|
133
|
+
{/snippet}
|
134
|
+
</form.Subscribe>
|
135
|
+
</form>
|
136
|
+
|
137
|
+
<div class="mt-4 text-center">
|
138
|
+
<button type="button" class="text-indigo-600 hover:text-indigo-800" onclick={switchToSignIn}>
|
139
|
+
Already have an account? Sign In
|
140
|
+
</button>
|
141
|
+
</div>
|
142
|
+
</div>
|
@@ -0,0 +1,54 @@
|
|
1
|
+
<script lang="ts">
|
2
|
+
import { authClient } from '$lib/auth-client';
|
3
|
+
import { goto } from '$app/navigation';
|
4
|
+
import { queryClient } from '$lib/orpc';
|
5
|
+
|
6
|
+
const sessionQuery = authClient.useSession();
|
7
|
+
|
8
|
+
async function handleSignOut() {
|
9
|
+
await authClient.signOut({
|
10
|
+
fetchOptions: {
|
11
|
+
onSuccess: () => {
|
12
|
+
queryClient.invalidateQueries();
|
13
|
+
goto('/');
|
14
|
+
},
|
15
|
+
onError: (error) => {
|
16
|
+
console.error('Sign out failed:', error);
|
17
|
+
}
|
18
|
+
}
|
19
|
+
});
|
20
|
+
}
|
21
|
+
|
22
|
+
function goToLogin() {
|
23
|
+
goto('/login');
|
24
|
+
}
|
25
|
+
|
26
|
+
</script>
|
27
|
+
|
28
|
+
<div class="relative">
|
29
|
+
{#if $sessionQuery.isPending}
|
30
|
+
<div class="h-8 w-24 animate-pulse rounded bg-neutral-700"></div>
|
31
|
+
{:else if $sessionQuery.data?.user}
|
32
|
+
{@const user = $sessionQuery.data.user}
|
33
|
+
<div class="flex items-center gap-3">
|
34
|
+
<span class="text-sm text-neutral-300 hidden sm:inline" title={user.email}>
|
35
|
+
{user.name || user.email?.split('@')[0] || 'User'}
|
36
|
+
</span>
|
37
|
+
<button
|
38
|
+
onclick={handleSignOut}
|
39
|
+
class="rounded px-3 py-1 text-sm bg-red-600 hover:bg-red-700 text-white transition-colors"
|
40
|
+
>
|
41
|
+
Sign Out
|
42
|
+
</button>
|
43
|
+
</div>
|
44
|
+
{:else}
|
45
|
+
<div class="flex items-center gap-2">
|
46
|
+
<button
|
47
|
+
onclick={goToLogin}
|
48
|
+
class="rounded px-3 py-1 text-sm bg-indigo-600 hover:bg-indigo-700 text-white transition-colors"
|
49
|
+
>
|
50
|
+
Sign In
|
51
|
+
</button>
|
52
|
+
</div>
|
53
|
+
{/if}
|
54
|
+
</div>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<script lang="ts">
|
2
|
+
import { onMount } from 'svelte';
|
3
|
+
import { goto } from '$app/navigation';
|
4
|
+
import { authClient } from '$lib/auth-client';
|
5
|
+
import { orpc } from '$lib/orpc';
|
6
|
+
import { createQuery } from '@tanstack/svelte-query';
|
7
|
+
import { get } from 'svelte/store';
|
8
|
+
|
9
|
+
const sessionQuery = authClient.useSession();
|
10
|
+
|
11
|
+
const privateDataQuery = createQuery(orpc.privateData.queryOptions());
|
12
|
+
|
13
|
+
onMount(() => {
|
14
|
+
const { data: session, isPending } = get(sessionQuery);
|
15
|
+
if (!session && !isPending) {
|
16
|
+
goto('/login');
|
17
|
+
}
|
18
|
+
});
|
19
|
+
</script>
|
20
|
+
|
21
|
+
{#if $sessionQuery.isPending}
|
22
|
+
<div>Loading...</div>
|
23
|
+
{:else if !$sessionQuery.data}
|
24
|
+
<!-- Redirecting... -->
|
25
|
+
{:else}
|
26
|
+
<div>
|
27
|
+
<h1>Dashboard</h1>
|
28
|
+
<p>Welcome {$sessionQuery.data.user.name}</p>
|
29
|
+
<p>privateData: {$privateDataQuery.data?.message}</p>
|
30
|
+
</div>
|
31
|
+
{/if}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<script lang="ts">
|
2
|
+
import SignInForm from '../../components/SignInForm.svelte';
|
3
|
+
import SignUpForm from '../../components/SignUpForm.svelte';
|
4
|
+
|
5
|
+
let showSignIn = $state(true);
|
6
|
+
</script>
|
7
|
+
|
8
|
+
{#if showSignIn}
|
9
|
+
<SignInForm switchToSignUp={() => showSignIn = false} />
|
10
|
+
{:else}
|
11
|
+
<SignUpForm switchToSignIn={() => showSignIn = true} />
|
12
|
+
{/if}
|