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,90 @@
|
|
1
|
+
# Welcome to your Convex functions directory!
|
2
|
+
|
3
|
+
Write your Convex functions here.
|
4
|
+
See https://docs.convex.dev/functions for more.
|
5
|
+
|
6
|
+
A query function that takes two arguments looks like:
|
7
|
+
|
8
|
+
```ts
|
9
|
+
// functions.js
|
10
|
+
import { query } from "./_generated/server";
|
11
|
+
import { v } from "convex/values";
|
12
|
+
|
13
|
+
export const myQueryFunction = query({
|
14
|
+
// Validators for arguments.
|
15
|
+
args: {
|
16
|
+
first: v.number(),
|
17
|
+
second: v.string(),
|
18
|
+
},
|
19
|
+
|
20
|
+
// Function implementation.
|
21
|
+
handler: async (ctx, args) => {
|
22
|
+
// Read the database as many times as you need here.
|
23
|
+
// See https://docs.convex.dev/database/reading-data.
|
24
|
+
const documents = await ctx.db.query("tablename").collect();
|
25
|
+
|
26
|
+
// Arguments passed from the client are properties of the args object.
|
27
|
+
console.log(args.first, args.second);
|
28
|
+
|
29
|
+
// Write arbitrary JavaScript here: filter, aggregate, build derived data,
|
30
|
+
// remove non-public properties, or create new objects.
|
31
|
+
return documents;
|
32
|
+
},
|
33
|
+
});
|
34
|
+
```
|
35
|
+
|
36
|
+
Using this query function in a React component looks like:
|
37
|
+
|
38
|
+
```ts
|
39
|
+
const data = useQuery(api.functions.myQueryFunction, {
|
40
|
+
first: 10,
|
41
|
+
second: "hello",
|
42
|
+
});
|
43
|
+
```
|
44
|
+
|
45
|
+
A mutation function looks like:
|
46
|
+
|
47
|
+
```ts
|
48
|
+
// functions.js
|
49
|
+
import { mutation } from "./_generated/server";
|
50
|
+
import { v } from "convex/values";
|
51
|
+
|
52
|
+
export const myMutationFunction = mutation({
|
53
|
+
// Validators for arguments.
|
54
|
+
args: {
|
55
|
+
first: v.string(),
|
56
|
+
second: v.string(),
|
57
|
+
},
|
58
|
+
|
59
|
+
// Function implementation.
|
60
|
+
handler: async (ctx, args) => {
|
61
|
+
// Insert or modify documents in the database here.
|
62
|
+
// Mutations can also read from the database like queries.
|
63
|
+
// See https://docs.convex.dev/database/writing-data.
|
64
|
+
const message = { body: args.first, author: args.second };
|
65
|
+
const id = await ctx.db.insert("messages", message);
|
66
|
+
|
67
|
+
// Optionally, return a value from your mutation.
|
68
|
+
return await ctx.db.get(id);
|
69
|
+
},
|
70
|
+
});
|
71
|
+
```
|
72
|
+
|
73
|
+
Using this mutation function in a React component looks like:
|
74
|
+
|
75
|
+
```ts
|
76
|
+
const mutation = useMutation(api.functions.myMutationFunction);
|
77
|
+
function handleButtonPress() {
|
78
|
+
// fire and forget, the most common way to use mutations
|
79
|
+
mutation({ first: "Hello!", second: "me" });
|
80
|
+
// OR
|
81
|
+
// use the result once the mutation has completed
|
82
|
+
mutation({ first: "Hello!", second: "me" }).then((result) =>
|
83
|
+
console.log(result),
|
84
|
+
);
|
85
|
+
}
|
86
|
+
```
|
87
|
+
|
88
|
+
Use the Convex CLI to push your functions to a deployment. See everything
|
89
|
+
the Convex CLI can do by running `npx convex -h` in your project root
|
90
|
+
directory. To learn more, launch the docs with `npx convex docs`.
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import { query, mutation } from "./_generated/server";
|
2
|
+
import { v } from "convex/values";
|
3
|
+
|
4
|
+
export const getAll = query({
|
5
|
+
handler: async (ctx) => {
|
6
|
+
return await ctx.db.query("todos").collect();
|
7
|
+
},
|
8
|
+
});
|
9
|
+
|
10
|
+
export const create = mutation({
|
11
|
+
args: {
|
12
|
+
text: v.string(),
|
13
|
+
},
|
14
|
+
handler: async (ctx, args) => {
|
15
|
+
const newTodoId = await ctx.db.insert("todos", {
|
16
|
+
text: args.text,
|
17
|
+
completed: false,
|
18
|
+
});
|
19
|
+
return await ctx.db.get(newTodoId);
|
20
|
+
},
|
21
|
+
});
|
22
|
+
|
23
|
+
export const toggle = mutation({
|
24
|
+
args: {
|
25
|
+
id: v.id("todos"),
|
26
|
+
completed: v.boolean(),
|
27
|
+
},
|
28
|
+
handler: async (ctx, args) => {
|
29
|
+
await ctx.db.patch(args.id, { completed: args.completed });
|
30
|
+
return { success: true };
|
31
|
+
},
|
32
|
+
});
|
33
|
+
|
34
|
+
export const deleteTodo = mutation({
|
35
|
+
args: {
|
36
|
+
id: v.id("todos"),
|
37
|
+
},
|
38
|
+
handler: async (ctx, args) => {
|
39
|
+
await ctx.db.delete(args.id);
|
40
|
+
return { success: true };
|
41
|
+
},
|
42
|
+
});
|
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
/* This TypeScript project config describes the environment that
|
3
|
+
* Convex functions run in and is used to typecheck them.
|
4
|
+
* You can modify it, but some settings required to use Convex.
|
5
|
+
*/
|
6
|
+
"compilerOptions": {
|
7
|
+
/* These settings are not required by Convex and can be modified. */
|
8
|
+
"allowJs": true,
|
9
|
+
"strict": true,
|
10
|
+
"moduleResolution": "Bundler",
|
11
|
+
"jsx": "react-jsx",
|
12
|
+
"skipLibCheck": true,
|
13
|
+
"allowSyntheticDefaultImports": true,
|
14
|
+
|
15
|
+
/* These compiler options are required by Convex */
|
16
|
+
"target": "ESNext",
|
17
|
+
"lib": ["ES2021", "dom"],
|
18
|
+
"forceConsistentCasingInFileNames": true,
|
19
|
+
"module": "ESNext",
|
20
|
+
"isolatedModules": true,
|
21
|
+
"noEmit": true
|
22
|
+
},
|
23
|
+
"include": ["./**/*"],
|
24
|
+
"exclude": ["./_generated"]
|
25
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"name": "@{{projectName}}/backend",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"scripts": {
|
5
|
+
"dev": "convex dev",
|
6
|
+
"setup": "convex dev --configure --until-success"
|
7
|
+
},
|
8
|
+
"author": "",
|
9
|
+
"license": "ISC",
|
10
|
+
"description": "",
|
11
|
+
"devDependencies": {
|
12
|
+
"typescript": "^5.8.3"
|
13
|
+
},
|
14
|
+
"dependencies": {
|
15
|
+
"convex": "^1.23.0"
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import "dotenv/config";
|
2
|
+
{{#if (eq runtime "node")}}
|
3
|
+
import { node } from "@elysiajs/node";
|
4
|
+
{{/if}}
|
5
|
+
import { Elysia } from "elysia";
|
6
|
+
import { cors } from "@elysiajs/cors";
|
7
|
+
{{#if (eq api "trpc")}}
|
8
|
+
import { createContext } from "./lib/context";
|
9
|
+
import { appRouter } from "./routers/index";
|
10
|
+
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
|
11
|
+
{{/if}}
|
12
|
+
{{#if (eq api "orpc")}}
|
13
|
+
import { RPCHandler } from "@orpc/server/fetch";
|
14
|
+
import { appRouter } from "./routers";
|
15
|
+
import { createContext } from "./lib/context";
|
16
|
+
{{/if}}
|
17
|
+
{{#if auth}}
|
18
|
+
import { auth } from "./lib/auth";
|
19
|
+
{{/if}}
|
20
|
+
|
21
|
+
{{#if (eq api "orpc")}}
|
22
|
+
const handler = new RPCHandler(appRouter);
|
23
|
+
{{/if}}
|
24
|
+
|
25
|
+
{{#if (eq runtime "node")}}
|
26
|
+
const app = new Elysia({ adapter: node() })
|
27
|
+
{{else}}
|
28
|
+
const app = new Elysia()
|
29
|
+
{{/if}}
|
30
|
+
.use(
|
31
|
+
cors({
|
32
|
+
origin: process.env.CORS_ORIGIN || "",
|
33
|
+
methods: ["GET", "POST", "OPTIONS"],
|
34
|
+
{{#if auth}}
|
35
|
+
allowedHeaders: ["Content-Type", "Authorization"],
|
36
|
+
credentials: true,
|
37
|
+
{{/if}}
|
38
|
+
}),
|
39
|
+
)
|
40
|
+
{{#if auth}}
|
41
|
+
.all("/api/auth/*", async (context) => {
|
42
|
+
const { request } = context;
|
43
|
+
if (["POST", "GET"].includes(request.method)) {
|
44
|
+
return auth.handler(request);
|
45
|
+
}
|
46
|
+
context.error(405);
|
47
|
+
})
|
48
|
+
{{/if}}
|
49
|
+
{{#if (eq api "orpc")}}
|
50
|
+
.all('/rpc*', async (context) => {
|
51
|
+
const { response } = await handler.handle(context.request, {
|
52
|
+
prefix: '/rpc',
|
53
|
+
context: await createContext({ context })
|
54
|
+
})
|
55
|
+
return response ?? new Response('Not Found', { status: 404 })
|
56
|
+
})
|
57
|
+
{{/if}}
|
58
|
+
{{#if (eq api "trpc")}}
|
59
|
+
.all("/trpc/*", async (context) => {
|
60
|
+
const res = await fetchRequestHandler({
|
61
|
+
endpoint: "/trpc",
|
62
|
+
router: appRouter,
|
63
|
+
req: context.request,
|
64
|
+
createContext: () => createContext({ context }),
|
65
|
+
});
|
66
|
+
return res;
|
67
|
+
})
|
68
|
+
{{/if}}
|
69
|
+
.get("/", () => "OK")
|
70
|
+
.listen(3000, () => {
|
71
|
+
console.log("Server is running on http://localhost:3000");
|
72
|
+
});
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import "dotenv/config";
|
2
|
+
{{#if (eq api "trpc")}}
|
3
|
+
import { createExpressMiddleware } from "@trpc/server/adapters/express";
|
4
|
+
import { createContext } from "./lib/context";
|
5
|
+
import { appRouter } from "./routers/index";
|
6
|
+
{{/if}}
|
7
|
+
{{#if (eq api "orpc")}}
|
8
|
+
import { RPCHandler } from "@orpc/server/node";
|
9
|
+
import { appRouter } from "./routers";
|
10
|
+
{{#if auth}}
|
11
|
+
import { createContext } from "./lib/context";
|
12
|
+
{{/if}}
|
13
|
+
{{/if}}
|
14
|
+
import cors from "cors";
|
15
|
+
import express from "express";
|
16
|
+
{{#if (includes examples "ai")}}
|
17
|
+
import { streamText } from "ai";
|
18
|
+
import { google } from "@ai-sdk/google";
|
19
|
+
{{/if}}
|
20
|
+
{{#if auth}}
|
21
|
+
import { auth } from "./lib/auth";
|
22
|
+
import { toNodeHandler } from "better-auth/node";
|
23
|
+
{{/if}}
|
24
|
+
|
25
|
+
const app = express();
|
26
|
+
|
27
|
+
app.use(
|
28
|
+
cors({
|
29
|
+
origin: process.env.CORS_ORIGIN || "",
|
30
|
+
methods: ["GET", "POST", "OPTIONS"],
|
31
|
+
{{#if auth}}
|
32
|
+
allowedHeaders: ["Content-Type", "Authorization"],
|
33
|
+
credentials: true,
|
34
|
+
{{/if}}
|
35
|
+
})
|
36
|
+
);
|
37
|
+
|
38
|
+
{{#if auth}}
|
39
|
+
app.all("/api/auth{/*path}", toNodeHandler(auth));
|
40
|
+
{{/if}}
|
41
|
+
|
42
|
+
{{#if (eq api "trpc")}}
|
43
|
+
app.use(
|
44
|
+
"/trpc",
|
45
|
+
createExpressMiddleware({
|
46
|
+
router: appRouter,
|
47
|
+
createContext
|
48
|
+
})
|
49
|
+
);
|
50
|
+
{{/if}}
|
51
|
+
|
52
|
+
{{#if (eq api "orpc")}}
|
53
|
+
const handler = new RPCHandler(appRouter);
|
54
|
+
app.use('/rpc{*path}', async (req, res, next) => {
|
55
|
+
const { matched } = await handler.handle(req, res, {
|
56
|
+
prefix: '/rpc',
|
57
|
+
{{#if auth}}
|
58
|
+
context: await createContext({ req }),
|
59
|
+
{{else}}
|
60
|
+
context: {},
|
61
|
+
{{/if}}
|
62
|
+
});
|
63
|
+
if (matched) return;
|
64
|
+
next();
|
65
|
+
});
|
66
|
+
{{/if}}
|
67
|
+
|
68
|
+
app.use(express.json())
|
69
|
+
|
70
|
+
{{#if (includes examples "ai")}}
|
71
|
+
app.post("/ai", async (req, res) => {
|
72
|
+
const { messages = [] } = req.body || {};
|
73
|
+
const result = streamText({
|
74
|
+
model: google("gemini-1.5-flash"),
|
75
|
+
messages,
|
76
|
+
});
|
77
|
+
result.pipeDataStreamToResponse(res);
|
78
|
+
});
|
79
|
+
{{/if}}
|
80
|
+
|
81
|
+
app.get("/", (_req, res) => {
|
82
|
+
res.status(200).send("OK");
|
83
|
+
});
|
84
|
+
|
85
|
+
const port = process.env.PORT || 3000;
|
86
|
+
app.listen(port, () => {
|
87
|
+
console.log(`Server is running on port ${port}`);
|
88
|
+
});
|
@@ -0,0 +1,155 @@
|
|
1
|
+
import "dotenv/config";
|
2
|
+
import Fastify from "fastify";
|
3
|
+
import fastifyCors from "@fastify/cors";
|
4
|
+
|
5
|
+
{{#if (eq api "trpc")}}
|
6
|
+
import { fastifyTRPCPlugin, type FastifyTRPCPluginOptions } from "@trpc/server/adapters/fastify";
|
7
|
+
import { createContext } from "./lib/context";
|
8
|
+
import { appRouter, type AppRouter } from "./routers/index";
|
9
|
+
{{/if}}
|
10
|
+
|
11
|
+
{{#if (eq api "orpc")}}
|
12
|
+
import { RPCHandler } from "@orpc/server/node";
|
13
|
+
import { CORSPlugin } from "@orpc/server/plugins";
|
14
|
+
import { appRouter } from "./routers/index";
|
15
|
+
import { createServer } from "node:http";
|
16
|
+
{{#if auth}}
|
17
|
+
import { createContext } from "./lib/context";
|
18
|
+
{{/if}}
|
19
|
+
{{/if}}
|
20
|
+
|
21
|
+
{{#if (includes examples "ai")}}
|
22
|
+
import type { FastifyRequest, FastifyReply } from "fastify";
|
23
|
+
import { streamText, type Message } from "ai";
|
24
|
+
import { google } from "@ai-sdk/google";
|
25
|
+
{{/if}}
|
26
|
+
|
27
|
+
{{#if auth}}
|
28
|
+
import { auth } from "./lib/auth";
|
29
|
+
{{/if}}
|
30
|
+
|
31
|
+
const baseCorsConfig = {
|
32
|
+
origin: process.env.CORS_ORIGIN || "",
|
33
|
+
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
34
|
+
allowedHeaders: [
|
35
|
+
"Content-Type",
|
36
|
+
"Authorization",
|
37
|
+
"X-Requested-With"
|
38
|
+
],
|
39
|
+
credentials: true,
|
40
|
+
maxAge: 86400,
|
41
|
+
};
|
42
|
+
|
43
|
+
{{#if (eq api "orpc")}}
|
44
|
+
const handler = new RPCHandler(appRouter, {
|
45
|
+
plugins: [
|
46
|
+
new CORSPlugin({
|
47
|
+
origin: process.env.CORS_ORIGIN,
|
48
|
+
credentials: true,
|
49
|
+
allowHeaders: ["Content-Type", "Authorization"],
|
50
|
+
}),
|
51
|
+
],
|
52
|
+
});
|
53
|
+
|
54
|
+
const fastify = Fastify({
|
55
|
+
logger: true,
|
56
|
+
serverFactory: (fastifyHandler) => {
|
57
|
+
const server = createServer(async (req, res) => {
|
58
|
+
const { matched } = await handler.handle(req, res, {
|
59
|
+
context: await createContext(req.headers),
|
60
|
+
prefix: "/rpc",
|
61
|
+
});
|
62
|
+
|
63
|
+
if (matched) {
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
|
67
|
+
fastifyHandler(req, res);
|
68
|
+
});
|
69
|
+
|
70
|
+
return server;
|
71
|
+
},
|
72
|
+
});
|
73
|
+
{{else}}
|
74
|
+
const fastify = Fastify({
|
75
|
+
logger: true,
|
76
|
+
});
|
77
|
+
{{/if}}
|
78
|
+
|
79
|
+
fastify.register(fastifyCors, baseCorsConfig);
|
80
|
+
|
81
|
+
{{#if auth}}
|
82
|
+
fastify.route({
|
83
|
+
method: ["GET", "POST"],
|
84
|
+
url: "/api/auth/*",
|
85
|
+
async handler(request, reply) {
|
86
|
+
try {
|
87
|
+
const url = new URL(request.url, `http://${request.headers.host}`);
|
88
|
+
const headers = new Headers();
|
89
|
+
Object.entries(request.headers).forEach(([key, value]) => {
|
90
|
+
if (value) headers.append(key, value.toString());
|
91
|
+
});
|
92
|
+
const req = new Request(url.toString(), {
|
93
|
+
method: request.method,
|
94
|
+
headers,
|
95
|
+
body: request.body ? JSON.stringify(request.body) : undefined,
|
96
|
+
});
|
97
|
+
const response = await auth.handler(req);
|
98
|
+
reply.status(response.status);
|
99
|
+
response.headers.forEach((value, key) => reply.header(key, value));
|
100
|
+
reply.send(response.body ? await response.text() : null);
|
101
|
+
} catch (error) {
|
102
|
+
fastify.log.error("Authentication Error:", error);
|
103
|
+
reply.status(500).send({
|
104
|
+
error: "Internal authentication error",
|
105
|
+
code: "AUTH_FAILURE"
|
106
|
+
});
|
107
|
+
}
|
108
|
+
}
|
109
|
+
});
|
110
|
+
{{/if}}
|
111
|
+
|
112
|
+
{{#if (eq api "trpc")}}
|
113
|
+
fastify.register(fastifyTRPCPlugin, {
|
114
|
+
prefix: "/trpc",
|
115
|
+
trpcOptions: {
|
116
|
+
router: appRouter,
|
117
|
+
createContext,
|
118
|
+
onError({ path, error }) {
|
119
|
+
console.error(`Error in tRPC handler on path '${path}':`, error);
|
120
|
+
},
|
121
|
+
} satisfies FastifyTRPCPluginOptions<AppRouter>["trpcOptions"],
|
122
|
+
});
|
123
|
+
{{/if}}
|
124
|
+
|
125
|
+
{{#if (includes examples "ai")}}
|
126
|
+
interface AiRequestBody {
|
127
|
+
id?: string;
|
128
|
+
messages: Message[];
|
129
|
+
}
|
130
|
+
|
131
|
+
fastify.post('/ai', async function (request, reply) {
|
132
|
+
const { messages } = request.body as AiRequestBody;
|
133
|
+
const result = streamText({
|
134
|
+
model: google('gemini-1.5-flash'),
|
135
|
+
messages,
|
136
|
+
});
|
137
|
+
|
138
|
+
reply.header('X-Vercel-AI-Data-Stream', 'v1');
|
139
|
+
reply.header('Content-Type', 'text/plain; charset=utf-8');
|
140
|
+
|
141
|
+
return reply.send(result.toDataStream());
|
142
|
+
});
|
143
|
+
{{/if}}
|
144
|
+
|
145
|
+
fastify.get('/', async () => {
|
146
|
+
return 'OK'
|
147
|
+
})
|
148
|
+
|
149
|
+
fastify.listen({ port: 3000 }, (err) => {
|
150
|
+
if (err) {
|
151
|
+
fastify.log.error(err);
|
152
|
+
process.exit(1);
|
153
|
+
}
|
154
|
+
console.log("Server running on port 3000");
|
155
|
+
});
|
@@ -0,0 +1,133 @@
|
|
1
|
+
{{#if (or (eq runtime "bun") (eq runtime "node"))}}
|
2
|
+
import "dotenv/config";
|
3
|
+
{{/if}}
|
4
|
+
{{#if (eq runtime "workers")}}
|
5
|
+
import { env } from "cloudflare:workers";
|
6
|
+
{{/if}}
|
7
|
+
{{#if (eq api "orpc")}}
|
8
|
+
import { RPCHandler } from "@orpc/server/fetch";
|
9
|
+
import { createContext } from "./lib/context";
|
10
|
+
import { appRouter } from "./routers/index";
|
11
|
+
{{/if}}
|
12
|
+
{{#if (eq api "trpc")}}
|
13
|
+
import { trpcServer } from "@hono/trpc-server";
|
14
|
+
import { createContext } from "./lib/context";
|
15
|
+
import { appRouter } from "./routers/index";
|
16
|
+
{{/if}}
|
17
|
+
{{#if auth}}
|
18
|
+
import { auth } from "./lib/auth";
|
19
|
+
{{/if}}
|
20
|
+
import { Hono } from "hono";
|
21
|
+
import { cors } from "hono/cors";
|
22
|
+
import { logger } from "hono/logger";
|
23
|
+
{{#if (and (includes examples "ai") (or (eq runtime "bun") (eq runtime "node")))}}
|
24
|
+
import { streamText } from "ai";
|
25
|
+
import { google } from "@ai-sdk/google";
|
26
|
+
import { stream } from "hono/streaming";
|
27
|
+
{{/if}}
|
28
|
+
{{#if (and (includes examples "ai") (eq runtime "workers"))}}
|
29
|
+
import { streamText } from "ai";
|
30
|
+
import { stream } from "hono/streaming";
|
31
|
+
import { createGoogleGenerativeAI } from "@ai-sdk/google";
|
32
|
+
{{/if}}
|
33
|
+
|
34
|
+
const app = new Hono();
|
35
|
+
|
36
|
+
app.use(logger());
|
37
|
+
app.use("/*", cors({
|
38
|
+
{{#if (or (eq runtime "bun") (eq runtime "node"))}}
|
39
|
+
origin: process.env.CORS_ORIGIN || "",
|
40
|
+
{{/if}}
|
41
|
+
{{#if (eq runtime "workers")}}
|
42
|
+
origin: env.CORS_ORIGIN || "",
|
43
|
+
{{/if}}
|
44
|
+
allowMethods: ["GET", "POST", "OPTIONS"],
|
45
|
+
{{#if auth}}
|
46
|
+
allowHeaders: ["Content-Type", "Authorization"],
|
47
|
+
credentials: true,
|
48
|
+
{{/if}}
|
49
|
+
}));
|
50
|
+
|
51
|
+
{{#if auth}}
|
52
|
+
app.on(["POST", "GET"], "/api/auth/**", (c) => auth.handler(c.req.raw));
|
53
|
+
{{/if}}
|
54
|
+
|
55
|
+
{{#if (eq api "orpc")}}
|
56
|
+
const handler = new RPCHandler(appRouter);
|
57
|
+
app.use("/rpc/*", async (c, next) => {
|
58
|
+
const context = await createContext({ context: c });
|
59
|
+
const { matched, response } = await handler.handle(c.req.raw, {
|
60
|
+
prefix: "/rpc",
|
61
|
+
context: context,
|
62
|
+
});
|
63
|
+
|
64
|
+
if (matched) {
|
65
|
+
return c.newResponse(response.body, response);
|
66
|
+
}
|
67
|
+
await next();
|
68
|
+
});
|
69
|
+
{{/if}}
|
70
|
+
|
71
|
+
{{#if (eq api "trpc")}}
|
72
|
+
app.use("/trpc/*", trpcServer({
|
73
|
+
router: appRouter,
|
74
|
+
createContext: (_opts, context) => {
|
75
|
+
return createContext({ context });
|
76
|
+
},
|
77
|
+
}));
|
78
|
+
{{/if}}
|
79
|
+
|
80
|
+
{{#if (and (includes examples "ai") (or (eq runtime "bun") (eq runtime "node")))}}
|
81
|
+
app.post("/ai", async (c) => {
|
82
|
+
const body = await c.req.json();
|
83
|
+
const messages = body.messages || [];
|
84
|
+
const result = streamText({
|
85
|
+
model: google("gemini-1.5-flash"),
|
86
|
+
messages,
|
87
|
+
});
|
88
|
+
|
89
|
+
c.header("X-Vercel-AI-Data-Stream", "v1");
|
90
|
+
c.header("Content-Type", "text/plain; charset=utf-8");
|
91
|
+
return stream(c, (stream) => stream.pipe(result.toDataStream()));
|
92
|
+
});
|
93
|
+
{{/if}}
|
94
|
+
|
95
|
+
{{#if (and (includes examples "ai") (eq runtime "workers"))}}
|
96
|
+
app.post("/ai", async (c) => {
|
97
|
+
const body = await c.req.json();
|
98
|
+
const messages = body.messages || [];
|
99
|
+
const google = createGoogleGenerativeAI({
|
100
|
+
apiKey: env.GOOGLE_GENERATIVE_AI_API_KEY,
|
101
|
+
});
|
102
|
+
const result = streamText({
|
103
|
+
model: google("gemini-1.5-flash"),
|
104
|
+
messages,
|
105
|
+
});
|
106
|
+
|
107
|
+
c.header("X-Vercel-AI-Data-Stream", "v1");
|
108
|
+
c.header("Content-Type", "text/plain; charset=utf-8");
|
109
|
+
return stream(c, (stream) => stream.pipe(result.toDataStream()));
|
110
|
+
});
|
111
|
+
{{/if}}
|
112
|
+
|
113
|
+
app.get("/", (c) => {
|
114
|
+
return c.text("OK");
|
115
|
+
});
|
116
|
+
|
117
|
+
{{#if (eq runtime "node")}}
|
118
|
+
import { serve } from "@hono/node-server";
|
119
|
+
|
120
|
+
serve({
|
121
|
+
fetch: app.fetch,
|
122
|
+
port: 3000,
|
123
|
+
}, (info) => {
|
124
|
+
console.log(`Server is running on http://localhost:${info.port}`);
|
125
|
+
});
|
126
|
+
{{else}}
|
127
|
+
{{#if (eq runtime "bun")}}
|
128
|
+
export default app;
|
129
|
+
{{/if}}
|
130
|
+
{{#if (eq runtime "workers")}}
|
131
|
+
export default app;
|
132
|
+
{{/if}}
|
133
|
+
{{/if}}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"name": "server",
|
3
|
+
"version": "0.1.0",
|
4
|
+
"private": true,
|
5
|
+
"scripts": {
|
6
|
+
"dev": "next dev --turbopack",
|
7
|
+
"build": "next build",
|
8
|
+
"start": "next start"
|
9
|
+
},
|
10
|
+
"dependencies": {
|
11
|
+
"next": "15.3.0",
|
12
|
+
"dotenv": "^16.5.0"
|
13
|
+
},
|
14
|
+
{{#if (eq dbSetup 'supabase')}}
|
15
|
+
"trustedDependencies": [
|
16
|
+
"supabase"
|
17
|
+
],
|
18
|
+
{{/if}}
|
19
|
+
"devDependencies": {
|
20
|
+
"@types/node": "^20",
|
21
|
+
"@types/react": "^19",
|
22
|
+
"typescript": "^5"
|
23
|
+
}
|
24
|
+
}
|