create-better-t-stack 1.13.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +95 -197
- package/package.json +72 -69
- package/templates/api/orpc/server/base/src/lib/context.ts.hbs +105 -0
- package/templates/api/orpc/server/base/src/lib/orpc.ts.hbs +17 -0
- package/templates/api/orpc/server/next/src/app/rpc/[...all]/route.ts.hbs +23 -0
- package/templates/api/orpc/web/base/src/utils/orpc.ts.hbs +57 -0
- package/templates/api/trpc/server/base/src/lib/context.ts.hbs +108 -0
- package/{template/with-auth/apps/server/src/lib/trpc.ts → templates/api/trpc/server/base/src/lib/trpc.ts.hbs} +2 -0
- package/templates/api/trpc/web/base/src/utils/trpc.ts.hbs +100 -0
- package/templates/auth/server/base/src/lib/auth.ts.hbs +30 -0
- package/templates/auth/web/base/src/lib/auth-client.ts.hbs +10 -0
- package/{template/with-auth/apps/web-next/src/app/dashboard/page.tsx → templates/auth/web/next/src/app/dashboard/page.tsx.hbs} +10 -0
- package/{template/with-auth/apps/web-react-router/src/routes/dashboard.tsx → templates/auth/web/react-router/src/routes/dashboard.tsx.hbs} +10 -0
- package/{template/with-auth/apps/web-tanstack-router/src/routes/dashboard.tsx → templates/auth/web/tanstack-router/src/routes/dashboard.tsx.hbs} +10 -0
- package/{template/with-auth/apps/web-tanstack-start/src/routes/dashboard.tsx → templates/auth/web/tanstack-start/src/routes/dashboard.tsx.hbs} +15 -0
- package/{template/with-auth/apps/server/src/with-elysia-index.ts → templates/backend/elysia/src/index.ts.hbs} +38 -3
- package/templates/backend/express/src/index.ts.hbs +78 -0
- package/templates/backend/hono/src/index.ts.hbs +105 -0
- package/{template/with-next/apps/server → templates/backend/next}/package.json +0 -2
- package/{template/base/apps/server → templates/backend/server-base}/package.json +0 -1
- package/templates/backend/server-base/src/routers/index.ts.hbs +51 -0
- package/templates/base/package.json +10 -0
- package/templates/examples/todo/server/drizzle/base/src/routers/todo.ts.hbs +79 -0
- package/{template/with-drizzle-sqlite/apps/server → templates/examples/todo/server/drizzle/sqlite}/src/db/schema/todo.ts +2 -2
- package/{template/examples/todo/apps/web-react-router/src/routes/todos.tsx → templates/examples/todo/web/react-router/src/routes/todos.tsx.hbs} +28 -0
- package/{template/examples/todo/apps/web-tanstack-router/src/routes/todos.tsx → templates/examples/todo/web/tanstack-router/src/routes/todos.tsx.hbs} +28 -0
- package/{template/examples/todo/apps/web-tanstack-start/src/routes/todos.tsx → templates/examples/todo/web/tanstack-start/src/routes/todos.tsx.hbs} +33 -0
- package/{template/base/apps/web-next → templates/frontend/next}/package.json +0 -2
- package/{template/base/apps/web-next/src/app/page.tsx → templates/frontend/next/src/app/page.tsx.hbs} +10 -0
- package/{template/base/apps/web-next/src/components/providers.tsx → templates/frontend/next/src/components/providers.tsx.hbs} +12 -0
- package/{template/base/apps/web-react-router → templates/frontend/react-router}/package.json +0 -3
- package/{template/base/apps/web-react-router/src/root.tsx → templates/frontend/react-router/src/root.tsx.hbs} +28 -1
- package/{template/base/apps/web-react-router/src/routes/_index.tsx → templates/frontend/react-router/src/routes/_index.tsx.hbs} +11 -0
- package/templates/frontend/react-router/vite.config.ts.hbs +37 -0
- package/{template/base/apps/web-tanstack-router → templates/frontend/tanstack-router}/package.json +0 -4
- package/{template/base/apps/web-tanstack-router/src/main.tsx → templates/frontend/tanstack-router/src/main.tsx.hbs} +20 -0
- package/{template/base/apps/web-tanstack-router/src/routes/__root.tsx → templates/frontend/tanstack-router/src/routes/__root.tsx.hbs} +48 -0
- package/{template/base/apps/web-tanstack-router/src/routes/index.tsx → templates/frontend/tanstack-router/src/routes/index.tsx.hbs} +10 -0
- package/templates/frontend/tanstack-router/vite.config.ts.hbs +43 -0
- package/{template/base/apps/web-tanstack-start → templates/frontend/tanstack-start}/package.json +0 -3
- package/{template/with-auth/apps/web-tanstack-start/src/router.tsx → templates/frontend/tanstack-start/src/router.tsx.hbs} +29 -3
- package/{template/base/apps/web-tanstack-start/src/routes/__root.tsx → templates/frontend/tanstack-start/src/routes/__root.tsx.hbs} +13 -0
- package/{template/base/apps/web-tanstack-start/src/routes/index.tsx → templates/frontend/tanstack-start/src/routes/index.tsx.hbs} +11 -0
- package/templates/frontend/web-base/src/components/header.tsx.hbs +80 -0
- package/template/base/apps/server/src/lib/trpc.ts +0 -8
- package/template/base/apps/server/src/routers/index.ts +0 -11
- package/template/base/apps/web-base/src/utils/trpc.ts +0 -33
- package/template/base/apps/web-next/src/components/header.tsx +0 -30
- package/template/base/apps/web-next/src/utils/trpc.ts +0 -33
- package/template/base/apps/web-react-router/src/components/header.tsx +0 -31
- package/template/base/apps/web-react-router/vite.config.ts +0 -8
- package/template/base/apps/web-tanstack-router/src/components/header.tsx +0 -31
- package/template/base/apps/web-tanstack-router/vite.config.ts +0 -14
- package/template/base/apps/web-tanstack-start/src/components/header.tsx +0 -27
- package/template/base/apps/web-tanstack-start/src/router.tsx +0 -70
- package/template/base/apps/web-tanstack-start/src/utils/trpc.ts +0 -5
- package/template/base/package.json +0 -18
- package/template/examples/todo/apps/server/src/routers/with-drizzle-todo.ts +0 -34
- package/template/with-auth/apps/server/src/lib/with-elysia-context.ts +0 -18
- package/template/with-auth/apps/server/src/lib/with-express-context.ts +0 -14
- package/template/with-auth/apps/server/src/lib/with-hono-context.ts +0 -18
- package/template/with-auth/apps/server/src/lib/with-next-context.ts +0 -14
- package/template/with-auth/apps/server/src/routers/index.ts +0 -17
- package/template/with-auth/apps/server/src/with-drizzle-mysql-lib/auth.ts +0 -15
- package/template/with-auth/apps/server/src/with-drizzle-postgres-lib/auth.ts +0 -15
- package/template/with-auth/apps/server/src/with-drizzle-sqlite-lib/auth.ts +0 -15
- package/template/with-auth/apps/server/src/with-express-index.ts +0 -34
- package/template/with-auth/apps/server/src/with-hono-index.ts +0 -39
- package/template/with-auth/apps/server/src/with-prisma-mongodb-lib/auth.ts +0 -11
- package/template/with-auth/apps/server/src/with-prisma-mysql-lib/auth.ts +0 -11
- package/template/with-auth/apps/server/src/with-prisma-postgres-lib/auth.ts +0 -11
- package/template/with-auth/apps/server/src/with-prisma-sqlite-lib/auth.ts +0 -11
- package/template/with-auth/apps/web-base/src/lib/auth-client.ts +0 -5
- package/template/with-auth/apps/web-next/src/components/header.tsx +0 -33
- package/template/with-auth/apps/web-next/src/lib/auth-client.ts +0 -5
- package/template/with-auth/apps/web-next/src/utils/trpc.ts +0 -39
- package/template/with-auth/apps/web-react-router/src/components/header.tsx +0 -34
- package/template/with-auth/apps/web-react-router/src/utils/trpc.ts +0 -39
- package/template/with-auth/apps/web-tanstack-router/src/components/header.tsx +0 -34
- package/template/with-auth/apps/web-tanstack-router/src/utils/trpc.ts +0 -39
- package/template/with-auth/apps/web-tanstack-start/src/components/header.tsx +0 -32
- package/template/with-elysia/apps/server/src/index.ts +0 -27
- package/template/with-elysia/apps/server/src/lib/context.ts +0 -13
- package/template/with-express/apps/server/src/index.ts +0 -29
- package/template/with-express/apps/server/src/lib/context.ts +0 -9
- package/template/with-hono/apps/server/src/index.ts +0 -33
- package/template/with-hono/apps/server/src/lib/context.ts +0 -13
- package/template/with-next/apps/server/src/lib/context.ts +0 -9
- /package/{template/with-biome → templates/addons/biome}/biome.json +0 -0
- /package/{template/with-husky → templates/addons/husky}/.husky/pre-commit +0 -0
- /package/{template/with-pwa → templates/addons/pwa}/apps/web/public/logo.png +0 -0
- /package/{template/with-pwa → templates/addons/pwa}/apps/web/pwa-assets.config.ts +0 -0
- /package/{template/base → templates/addons/turborepo}/turbo.json +0 -0
- /package/{template/with-next/apps/server → templates/api/trpc/server/next}/src/app/trpc/[trpc]/route.ts +0 -0
- /package/{template/with-auth/apps → templates/auth}/native/app/(drawer)/index.tsx +0 -0
- /package/{template/with-auth/apps → templates/auth}/native/components/sign-in.tsx +0 -0
- /package/{template/with-auth/apps → templates/auth}/native/components/sign-up.tsx +0 -0
- /package/{template/with-auth/apps → templates/auth}/native/lib/auth-client.ts +0 -0
- /package/{template/with-auth/apps → templates/auth}/native/utils/trpc.ts +0 -0
- /package/{template/with-drizzle-mysql/apps/server → templates/auth/server/db/drizzle/mysql}/src/db/schema/auth.ts +0 -0
- /package/{template/with-drizzle-postgres/apps/server → templates/auth/server/db/drizzle/postgres}/src/db/schema/auth.ts +0 -0
- /package/{template/with-drizzle-sqlite/apps/server → templates/auth/server/db/drizzle/sqlite}/src/db/schema/auth.ts +0 -0
- /package/{template/with-prisma-sqlite/apps/server → templates/auth/server/db/prisma/mongodb}/prisma/schema/auth.prisma +0 -0
- /package/{template/with-prisma-mysql/apps/server → templates/auth/server/db/prisma/mysql}/prisma/schema/auth.prisma +0 -0
- /package/{template/with-prisma-postgres/apps/server → templates/auth/server/db/prisma/postgres}/prisma/schema/auth.prisma +0 -0
- /package/{template/with-prisma-mongodb/apps/server → templates/auth/server/db/prisma/sqlite}/prisma/schema/auth.prisma +0 -0
- /package/{template/with-auth/apps/server/src/with-next-app → templates/auth/server/next/src/app}/api/auth/[...all]/route.ts +0 -0
- /package/{template/with-auth/apps/web-next → templates/auth/web/next}/src/app/login/page.tsx +0 -0
- /package/{template/with-auth/apps/web-next → templates/auth/web/next}/src/components/sign-in-form.tsx +0 -0
- /package/{template/with-auth/apps/web-next → templates/auth/web/next}/src/components/sign-up-form.tsx +0 -0
- /package/{template/with-auth/apps/web-next → templates/auth/web/next}/src/components/theme-provider.tsx +0 -0
- /package/{template/with-auth/apps/web-next → templates/auth/web/next}/src/components/user-menu.tsx +0 -0
- /package/{template/with-auth/apps/web-react-router → templates/auth/web/react-router}/src/components/sign-in-form.tsx +0 -0
- /package/{template/with-auth/apps/web-react-router → templates/auth/web/react-router}/src/components/sign-up-form.tsx +0 -0
- /package/{template/with-auth/apps/web-react-router → templates/auth/web/react-router}/src/components/user-menu.tsx +0 -0
- /package/{template/with-auth/apps/web-react-router → templates/auth/web/react-router}/src/routes/login.tsx +0 -0
- /package/{template/with-auth/apps/web-tanstack-start → templates/auth/web/tanstack-router}/src/components/sign-in-form.tsx +0 -0
- /package/{template/with-auth/apps/web-tanstack-start → templates/auth/web/tanstack-router}/src/components/sign-up-form.tsx +0 -0
- /package/{template/with-auth/apps/web-tanstack-start → templates/auth/web/tanstack-router}/src/components/user-menu.tsx +0 -0
- /package/{template/with-auth/apps/web-tanstack-start → templates/auth/web/tanstack-router}/src/routes/login.tsx +0 -0
- /package/{template/with-auth/apps/web-tanstack-router → templates/auth/web/tanstack-start}/src/components/sign-in-form.tsx +0 -0
- /package/{template/with-auth/apps/web-tanstack-router → templates/auth/web/tanstack-start}/src/components/sign-up-form.tsx +0 -0
- /package/{template/with-auth/apps/web-tanstack-router → templates/auth/web/tanstack-start}/src/components/user-menu.tsx +0 -0
- /package/{template/with-auth/apps/web-tanstack-router → templates/auth/web/tanstack-start}/src/routes/login.tsx +0 -0
- /package/{template/with-next/apps/server → templates/backend/next}/next-env.d.ts +0 -0
- /package/{template/with-next/apps/server → templates/backend/next}/next.config.ts +0 -0
- /package/{template/with-next/apps/server → templates/backend/next}/src/app/route.ts +0 -0
- /package/{template/with-next/apps/server → templates/backend/next}/src/middleware.ts +0 -0
- /package/{template/with-next/apps/server → templates/backend/next}/tsconfig.json +0 -0
- /package/{template/base/apps/server → templates/backend/server-base}/_gitignore +0 -0
- /package/{template/base/apps/server → templates/backend/server-base}/tsconfig.json +0 -0
- /package/{template → templates}/base/_gitignore +0 -0
- /package/{template/with-drizzle-mysql/apps/server → templates/db/drizzle/mysql}/drizzle.config.ts +0 -0
- /package/{template/with-drizzle-mysql/apps/server → templates/db/drizzle/mysql}/src/db/index.ts +0 -0
- /package/{template/with-drizzle-postgres/apps/server → templates/db/drizzle/postgres}/drizzle.config.ts +0 -0
- /package/{template/with-drizzle-postgres/apps/server → templates/db/drizzle/postgres}/src/db/index.ts +0 -0
- /package/{template/with-drizzle-sqlite/apps/server → templates/db/drizzle/sqlite}/drizzle.config.ts +0 -0
- /package/{template/with-drizzle-sqlite/apps/server → templates/db/drizzle/sqlite}/src/db/index.ts +0 -0
- /package/{template/with-prisma-sqlite/apps/server → templates/db/prisma/mongodb}/prisma/index.ts +0 -0
- /package/{template/with-prisma-mongodb/apps/server → templates/db/prisma/mongodb}/prisma/schema/schema.prisma +0 -0
- /package/{template/with-prisma-postgres/apps/server → templates/db/prisma/mysql}/prisma/index.ts +0 -0
- /package/{template/with-prisma-mysql/apps/server → templates/db/prisma/mysql}/prisma/schema/schema.prisma +0 -0
- /package/{template/with-prisma-mysql/apps/server → templates/db/prisma/postgres}/prisma/index.ts +0 -0
- /package/{template/with-prisma-postgres/apps/server → templates/db/prisma/postgres}/prisma/schema/schema.prisma +0 -0
- /package/{template/with-prisma-mongodb/apps/server → templates/db/prisma/sqlite}/prisma/index.ts +0 -0
- /package/{template/with-prisma-sqlite/apps/server → templates/db/prisma/sqlite}/prisma/schema/schema.prisma +0 -0
- /package/{template/examples/ai/apps/web-react-router → templates/examples/ai/apps/react-router}/src/routes/ai.tsx +0 -0
- /package/{template/examples/ai/apps/web-tanstack-start → templates/examples/ai/apps/tanstack-router}/src/routes/ai.tsx +0 -0
- /package/{template/examples/ai/apps/web-tanstack-router → templates/examples/ai/apps/tanstack-start}/src/routes/ai.tsx +0 -0
- /package/{template/with-drizzle-mysql/apps/server → templates/examples/todo/server/drizzle/mysql}/src/db/schema/todo.ts +0 -0
- /package/{template/with-drizzle-postgres/apps/server → templates/examples/todo/server/drizzle/postgres}/src/db/schema/todo.ts +0 -0
- /package/{template/examples/todo/apps/server/src/routers/with-prisma-todo.ts → templates/examples/todo/server/prisma/base/trpc/src/routers/todo.ts} +0 -0
- /package/{template/with-prisma-mongodb/apps/server → templates/examples/todo/server/prisma/mongodb}/prisma/schema/todo.prisma +0 -0
- /package/{template/with-prisma-sqlite/apps/server → templates/examples/todo/server/prisma/mysql}/prisma/schema/todo.prisma +0 -0
- /package/{template/with-prisma-postgres/apps/server → templates/examples/todo/server/prisma/postgres}/prisma/schema/todo.prisma +0 -0
- /package/{template/with-prisma-mysql/apps/server → templates/examples/todo/server/prisma/sqlite}/prisma/schema/todo.prisma +0 -0
- /package/{template/with-pnpm → templates/extras}/pnpm-workspace.yaml +0 -0
- /package/{template/base/apps → templates/frontend}/native/_gitignore +0 -0
- /package/{template/base/apps → templates/frontend}/native/app/(drawer)/(tabs)/_layout.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/app/(drawer)/(tabs)/index.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/app/(drawer)/(tabs)/two.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/app/(drawer)/_layout.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/app/(drawer)/index.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/app/+html.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/app/+not-found.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/app/_layout.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/app/modal.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/app-env.d.ts +0 -0
- /package/{template/base/apps → templates/frontend}/native/app.json +0 -0
- /package/{template/base/apps → templates/frontend}/native/assets/adaptive-icon.png +0 -0
- /package/{template/base/apps → templates/frontend}/native/assets/favicon.png +0 -0
- /package/{template/base/apps → templates/frontend}/native/assets/icon.png +0 -0
- /package/{template/base/apps → templates/frontend}/native/assets/splash.png +0 -0
- /package/{template/base/apps → templates/frontend}/native/babel.config.js +0 -0
- /package/{template/base/apps → templates/frontend}/native/components/container.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/components/header-button.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/components/tabbar-icon.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/global.css +0 -0
- /package/{template/base/apps → templates/frontend}/native/lib/android-navigation-bar.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/native/lib/constants.ts +0 -0
- /package/{template/base/apps → templates/frontend}/native/lib/use-color-scheme.ts +0 -0
- /package/{template/base/apps → templates/frontend}/native/metro.config.js +0 -0
- /package/{template/base/apps → templates/frontend}/native/package.json +0 -0
- /package/{template/base/apps → templates/frontend}/native/tailwind.config.js +0 -0
- /package/{template/base/apps → templates/frontend}/native/tsconfig.json +0 -0
- /package/{template/base/apps → templates/frontend}/native/utils/trpc.ts +0 -0
- /package/{template/base/apps/web-next → templates/frontend/next}/next-env.d.ts +0 -0
- /package/{template/base/apps/web-next → templates/frontend/next}/next.config.ts +0 -0
- /package/{template/base/apps/web-next → templates/frontend/next}/postcss.config.mjs +0 -0
- /package/{template/base/apps/web-next → templates/frontend/next}/src/app/favicon.ico +0 -0
- /package/{template/base/apps/web-next → templates/frontend/next}/src/app/layout.tsx +0 -0
- /package/{template/base/apps/web-next → templates/frontend/next}/src/components/mode-toggle.tsx +0 -0
- /package/{template/base/apps/web-next → templates/frontend/next}/src/components/theme-provider.tsx +0 -0
- /package/{template/base/apps/web-next → templates/frontend/next}/tsconfig.json +0 -0
- /package/{template/base/apps/web-react-router → templates/frontend/react-router}/public/favicon.ico +0 -0
- /package/{template/base/apps/web-react-router → templates/frontend/react-router}/react-router.config.ts +0 -0
- /package/{template/base/apps/web-tanstack-router → templates/frontend/react-router}/src/components/mode-toggle.tsx +0 -0
- /package/{template/base/apps/web-tanstack-router → templates/frontend/react-router}/src/components/theme-provider.tsx +0 -0
- /package/{template/base/apps/web-react-router → templates/frontend/react-router}/src/routes.ts +0 -0
- /package/{template/base/apps/web-react-router → templates/frontend/react-router}/tsconfig.json +0 -0
- /package/{template/base/apps/web-tanstack-router → templates/frontend/tanstack-router}/index.html +0 -0
- /package/{template/base/apps/web-react-router → templates/frontend/tanstack-router}/src/components/mode-toggle.tsx +0 -0
- /package/{template/base/apps/web-react-router → templates/frontend/tanstack-router}/src/components/theme-provider.tsx +0 -0
- /package/{template/base/apps/web-tanstack-router → templates/frontend/tanstack-router}/tsconfig.json +0 -0
- /package/{template/base/apps/web-tanstack-start → templates/frontend/tanstack-start}/app.config.ts +0 -0
- /package/{template/base/apps/web-tanstack-start → templates/frontend/tanstack-start}/public/robots.txt +0 -0
- /package/{template/base/apps/web-tanstack-start → templates/frontend/tanstack-start}/src/api.ts +0 -0
- /package/{template/base/apps/web-tanstack-start → templates/frontend/tanstack-start}/src/client.tsx +0 -0
- /package/{template/base/apps/web-tanstack-start → templates/frontend/tanstack-start}/src/ssr.tsx +0 -0
- /package/{template/base/apps/web-tanstack-start → templates/frontend/tanstack-start}/tsconfig.json +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/_gitignore +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/components.json +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/components/loader.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/components/ui/button.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/components/ui/card.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/components/ui/checkbox.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/components/ui/dropdown-menu.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/components/ui/input.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/components/ui/label.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/components/ui/skeleton.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/components/ui/sonner.tsx +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/index.css +0 -0
- /package/{template/base/apps → templates/frontend}/web-base/src/lib/utils.ts +0 -0
package/package.json
CHANGED
|
@@ -1,71 +1,74 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
2
|
+
"name": "create-better-t-stack",
|
|
3
|
+
"version": "2.0.0",
|
|
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": "Aman Varshney",
|
|
8
|
+
"bin": {
|
|
9
|
+
"create-better-t-stack": "dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"templates",
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [
|
|
16
|
+
"better-t-stack",
|
|
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/AmanVarshney01/create-better-t-stack.git",
|
|
44
|
+
"directory": "apps/cli"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://better-t-stack.pages.dev/",
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsup",
|
|
49
|
+
"dev": "tsup --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.10.1",
|
|
57
|
+
"consola": "^3.4.2",
|
|
58
|
+
"execa": "^8.0.1",
|
|
59
|
+
"fs-extra": "^11.3.0",
|
|
60
|
+
"globby": "^14.1.0",
|
|
61
|
+
"gradient-string": "^3.0.0",
|
|
62
|
+
"handlebars": "^4.7.8",
|
|
63
|
+
"picocolors": "^1.1.1",
|
|
64
|
+
"yargs": "^17.7.2"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@types/fs-extra": "^11.0.4",
|
|
68
|
+
"@types/globby": "^9.1.0",
|
|
69
|
+
"@types/node": "^20.17.30",
|
|
70
|
+
"@types/yargs": "^17.0.33",
|
|
71
|
+
"tsup": "^8.4.0",
|
|
72
|
+
"typescript": "^5.8.3"
|
|
73
|
+
}
|
|
71
74
|
}
|
|
@@ -0,0 +1,105 @@
|
|
|
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
|
+
import type { CreateExpressContextOptions } from "@trpc/server/adapters/express";
|
|
74
|
+
{{#if auth}}
|
|
75
|
+
import { fromNodeHeaders } from "better-auth/node";
|
|
76
|
+
import { auth } from "./auth";
|
|
77
|
+
{{/if}}
|
|
78
|
+
|
|
79
|
+
export async function createContext(opts: CreateExpressContextOptions) {
|
|
80
|
+
{{#if auth}}
|
|
81
|
+
const session = await auth.api.getSession({
|
|
82
|
+
headers: fromNodeHeaders(opts.req.headers),
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
session,
|
|
86
|
+
};
|
|
87
|
+
{{else}}
|
|
88
|
+
// No auth configured
|
|
89
|
+
return {
|
|
90
|
+
session: null,
|
|
91
|
+
};
|
|
92
|
+
{{/if}}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
{{else}}
|
|
96
|
+
// Default or fallback context if backend is not recognized or none
|
|
97
|
+
// This might need adjustment based on your default behavior
|
|
98
|
+
export async function createContext() {
|
|
99
|
+
return {
|
|
100
|
+
session: null,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
{{/if}}
|
|
104
|
+
|
|
105
|
+
export type Context = Awaited<ReturnType<typeof createContext>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
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({ context });
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const protectedProcedure = publicProcedure.use(requireAuth);
|
|
17
|
+
{{/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,57 @@
|
|
|
1
|
+
import { createORPCClient } from "@orpc/client";
|
|
2
|
+
import { RPCLink } from "@orpc/client/fetch";
|
|
3
|
+
import { createORPCReactQueryUtils } from "@orpc/react-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
|
+
import { createContext, use } from 'react'
|
|
9
|
+
import type { RouterUtils } from '@orpc/react-query'
|
|
10
|
+
|
|
11
|
+
type ORPCReactUtils = RouterUtils<RouterClient<typeof appRouter>>
|
|
12
|
+
|
|
13
|
+
export const queryClient = new QueryClient({
|
|
14
|
+
queryCache: new QueryCache({
|
|
15
|
+
onError: (error) => {
|
|
16
|
+
toast.error(`Error: ${error.message}`, {
|
|
17
|
+
action: {
|
|
18
|
+
label: "retry",
|
|
19
|
+
onClick: () => {
|
|
20
|
+
queryClient.invalidateQueries();
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const link = new RPCLink({
|
|
29
|
+
{{#if (includes frontend "next")}}
|
|
30
|
+
url: `${process.env.NEXT_PUBLIC_SERVER_URL}/rpc`,
|
|
31
|
+
{{else}}
|
|
32
|
+
url: `${import.meta.env.VITE_SERVER_URL}/rpc`,
|
|
33
|
+
{{/if}}
|
|
34
|
+
{{#if auth}}
|
|
35
|
+
fetch(url, options) {
|
|
36
|
+
return fetch(url, {
|
|
37
|
+
...options,
|
|
38
|
+
credentials: "include",
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
{{/if}}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export const client: RouterClient<typeof appRouter> = createORPCClient(link)
|
|
45
|
+
|
|
46
|
+
export const orpc = createORPCReactQueryUtils(client)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
export const ORPCContext = createContext<ORPCReactUtils | undefined>(undefined)
|
|
50
|
+
|
|
51
|
+
export function useORPC(): ORPCReactUtils {
|
|
52
|
+
const orpc = use(ORPCContext)
|
|
53
|
+
if (!orpc) {
|
|
54
|
+
throw new Error('ORPCContext is not set up properly')
|
|
55
|
+
}
|
|
56
|
+
return orpc
|
|
57
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
// No auth configured
|
|
17
|
+
return {
|
|
18
|
+
session: null,
|
|
19
|
+
};
|
|
20
|
+
{{/if}}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
{{else if (eq backend 'hono')}}
|
|
24
|
+
import type { Context as HonoContext } from "hono";
|
|
25
|
+
{{#if auth}}
|
|
26
|
+
import { auth } from "./auth";
|
|
27
|
+
{{/if}}
|
|
28
|
+
|
|
29
|
+
export type CreateContextOptions = {
|
|
30
|
+
context: HonoContext;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export async function createContext({ context }: CreateContextOptions) {
|
|
34
|
+
{{#if auth}}
|
|
35
|
+
const session = await auth.api.getSession({
|
|
36
|
+
headers: context.req.raw.headers,
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
session,
|
|
40
|
+
};
|
|
41
|
+
{{else}}
|
|
42
|
+
// No auth configured
|
|
43
|
+
return {
|
|
44
|
+
session: null,
|
|
45
|
+
};
|
|
46
|
+
{{/if}}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
{{else if (eq backend 'elysia')}}
|
|
50
|
+
import type { Context as ElysiaContext } from "elysia";
|
|
51
|
+
{{#if auth}}
|
|
52
|
+
import { auth } from "./auth";
|
|
53
|
+
{{/if}}
|
|
54
|
+
|
|
55
|
+
export type CreateContextOptions = {
|
|
56
|
+
context: ElysiaContext;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export async function createContext({ context }: CreateContextOptions) {
|
|
60
|
+
{{#if auth}}
|
|
61
|
+
const session = await auth.api.getSession({
|
|
62
|
+
headers: context.request.headers,
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
session,
|
|
66
|
+
};
|
|
67
|
+
{{else}}
|
|
68
|
+
// No auth configured
|
|
69
|
+
return {
|
|
70
|
+
session: null,
|
|
71
|
+
};
|
|
72
|
+
{{/if}}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
{{else if (eq backend 'express')}}
|
|
76
|
+
import type { CreateExpressContextOptions } from "@trpc/server/adapters/express";
|
|
77
|
+
{{#if auth}}
|
|
78
|
+
import { fromNodeHeaders } from "better-auth/node";
|
|
79
|
+
import { auth } from "./auth";
|
|
80
|
+
{{/if}}
|
|
81
|
+
|
|
82
|
+
export async function createContext(opts: CreateExpressContextOptions) {
|
|
83
|
+
{{#if auth}}
|
|
84
|
+
const session = await auth.api.getSession({
|
|
85
|
+
headers: fromNodeHeaders(opts.req.headers),
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
session,
|
|
89
|
+
};
|
|
90
|
+
{{else}}
|
|
91
|
+
// No auth configured
|
|
92
|
+
return {
|
|
93
|
+
session: null,
|
|
94
|
+
};
|
|
95
|
+
{{/if}}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
{{else}}
|
|
99
|
+
// Default or fallback context if backend is not recognized or none
|
|
100
|
+
// This might need adjustment based on your default behavior
|
|
101
|
+
export async function createContext() {
|
|
102
|
+
return {
|
|
103
|
+
session: null,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
{{/if}}
|
|
107
|
+
|
|
108
|
+
export type Context = Awaited<ReturnType<typeof createContext>>;
|
|
@@ -7,6 +7,7 @@ export const router = t.router;
|
|
|
7
7
|
|
|
8
8
|
export const publicProcedure = t.procedure;
|
|
9
9
|
|
|
10
|
+
{{#if auth}}
|
|
10
11
|
export const protectedProcedure = t.procedure.use(({ ctx, next }) => {
|
|
11
12
|
if (!ctx.session) {
|
|
12
13
|
throw new TRPCError({
|
|
@@ -22,3 +23,4 @@ export const protectedProcedure = t.procedure.use(({ ctx, next }) => {
|
|
|
22
23
|
},
|
|
23
24
|
});
|
|
24
25
|
});
|
|
26
|
+
{{/if}}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
{{#if (includes frontend 'next')}}
|
|
2
|
+
{{!-- Next.js tRPC Client Setup --}}
|
|
3
|
+
import { QueryCache, QueryClient } from '@tanstack/react-query';
|
|
4
|
+
import { createTRPCClient, httpBatchLink } from '@trpc/client';
|
|
5
|
+
import { createTRPCOptionsProxy } from '@trpc/tanstack-react-query';
|
|
6
|
+
import type { AppRouter } from '../../../server/src/routers'; {{! Adjust path if necessary }}
|
|
7
|
+
import { toast } from 'sonner';
|
|
8
|
+
|
|
9
|
+
export const queryClient = new QueryClient({
|
|
10
|
+
queryCache: new QueryCache({
|
|
11
|
+
onError: (error) => {
|
|
12
|
+
toast.error(error.message, {
|
|
13
|
+
action: {
|
|
14
|
+
label: "retry",
|
|
15
|
+
onClick: () => {
|
|
16
|
+
queryClient.invalidateQueries();
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const trpcClient = createTRPCClient<AppRouter>({
|
|
25
|
+
links: [
|
|
26
|
+
httpBatchLink({
|
|
27
|
+
{{#if (includes frontend 'next')}}
|
|
28
|
+
url: `${process.env.NEXT_PUBLIC_SERVER_URL}/trpc`,
|
|
29
|
+
{{else}}
|
|
30
|
+
url: `${import.meta.env.VITE_SERVER_URL}/trpc`,
|
|
31
|
+
{{/if}}
|
|
32
|
+
{{#if auth}}
|
|
33
|
+
fetch(url, options) {
|
|
34
|
+
return fetch(url, {
|
|
35
|
+
...options,
|
|
36
|
+
credentials: "include",
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
{{/if}}
|
|
40
|
+
}),
|
|
41
|
+
],
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
export const trpc = createTRPCOptionsProxy<AppRouter>({
|
|
45
|
+
client: trpcClient,
|
|
46
|
+
queryClient,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
{{else if (includes frontend 'tanstack-start')}}
|
|
50
|
+
{{!-- TanStack Start tRPC Client Setup --}}
|
|
51
|
+
import { createTRPCContext } from "@trpc/tanstack-react-query";
|
|
52
|
+
import type { AppRouter } from "../../../server/src/routers"; {{! Adjust path if necessary }}
|
|
53
|
+
|
|
54
|
+
export const { TRPCProvider, useTRPC, useTRPCClient } =
|
|
55
|
+
createTRPCContext<AppRouter>();
|
|
56
|
+
|
|
57
|
+
{{else}}
|
|
58
|
+
{{!-- Default Web tRPC Client Setup (TanStack Router, React Router, etc.) --}}
|
|
59
|
+
import type { AppRouter } from "../../../server/src/routers"; {{! Adjust path if necessary }}
|
|
60
|
+
import { QueryCache, QueryClient } from "@tanstack/react-query";
|
|
61
|
+
import { createTRPCClient, httpBatchLink } from "@trpc/client";
|
|
62
|
+
import { createTRPCOptionsProxy } from "@trpc/tanstack-react-query";
|
|
63
|
+
import { toast } from "sonner";
|
|
64
|
+
|
|
65
|
+
export const queryClient = new QueryClient({
|
|
66
|
+
queryCache: new QueryCache({
|
|
67
|
+
onError: (error) => {
|
|
68
|
+
toast.error(error.message, {
|
|
69
|
+
action: {
|
|
70
|
+
label: "retry",
|
|
71
|
+
onClick: () => {
|
|
72
|
+
queryClient.invalidateQueries();
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
}),
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export const trpcClient = createTRPCClient<AppRouter>({
|
|
81
|
+
links: [
|
|
82
|
+
httpBatchLink({
|
|
83
|
+
url: `${import.meta.env.VITE_SERVER_URL}/trpc`,
|
|
84
|
+
{{#if auth}}
|
|
85
|
+
fetch(url, options) {
|
|
86
|
+
return fetch(url, {
|
|
87
|
+
...options,
|
|
88
|
+
credentials: "include",
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
{{/if}}
|
|
92
|
+
}),
|
|
93
|
+
],
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
export const trpc = createTRPCOptionsProxy<AppRouter>({
|
|
97
|
+
client: trpcClient,
|
|
98
|
+
queryClient,
|
|
99
|
+
});
|
|
100
|
+
{{/if}}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { betterAuth } from "better-auth";
|
|
2
|
+
|
|
3
|
+
{{#if (eq orm "prisma")}}
|
|
4
|
+
import { prismaAdapter } from "better-auth/adapters/prisma";
|
|
5
|
+
import prisma from "../../prisma";
|
|
6
|
+
|
|
7
|
+
export const auth = betterAuth({
|
|
8
|
+
database: prismaAdapter(prisma, {
|
|
9
|
+
provider: "{{database}}"
|
|
10
|
+
}),
|
|
11
|
+
trustedOrigins: [process.env.CORS_ORIGIN || ""],
|
|
12
|
+
emailAndPassword: { enabled: true }
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
{{else if (eq orm "drizzle")}}
|
|
16
|
+
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
17
|
+
import { db } from "../db";
|
|
18
|
+
import * as schema from "../db/schema/auth";
|
|
19
|
+
|
|
20
|
+
export const auth = betterAuth({
|
|
21
|
+
database: drizzleAdapter(db, {
|
|
22
|
+
{{#if (eq database "postgresql")}}provider: "pg",{{/if}}
|
|
23
|
+
{{#if (eq database "sqlite")}}provider: "sqlite",{{/if}}
|
|
24
|
+
{{#if (eq database "mysql")}}provider: "mysql",{{/if}}
|
|
25
|
+
schema: schema
|
|
26
|
+
}),
|
|
27
|
+
trustedOrigins: [process.env.CORS_ORIGIN || ""],
|
|
28
|
+
emailAndPassword: { enabled: true }
|
|
29
|
+
});
|
|
30
|
+
{{/if}}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { authClient } from "@/lib/auth-client";
|
|
3
|
+
{{#if (eq api "orpc")}}
|
|
4
|
+
import { orpc } from "@/utils/orpc";
|
|
5
|
+
{{/if}}
|
|
6
|
+
{{#if (eq api "trpc")}}
|
|
3
7
|
import { trpc } from "@/utils/trpc";
|
|
8
|
+
{{/if}}
|
|
4
9
|
import { useQuery } from "@tanstack/react-query";
|
|
5
10
|
import { useRouter } from "next/navigation";
|
|
6
11
|
import { useEffect } from "react";
|
|
@@ -9,7 +14,12 @@ export default function Dashboard() {
|
|
|
9
14
|
const router = useRouter()
|
|
10
15
|
const { data: session, isPending } = authClient.useSession();
|
|
11
16
|
|
|
17
|
+
{{#if (eq api "orpc")}}
|
|
18
|
+
const privateData = useQuery(orpc.privateData.queryOptions());
|
|
19
|
+
{{/if}}
|
|
20
|
+
{{#if (eq api "trpc")}}
|
|
12
21
|
const privateData = useQuery(trpc.privateData.queryOptions());
|
|
22
|
+
{{/if}}
|
|
13
23
|
|
|
14
24
|
useEffect(() => {
|
|
15
25
|
if (!session && !isPending) {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { authClient } from "@/lib/auth-client";
|
|
2
|
+
{{#if (eq api "orpc")}}
|
|
3
|
+
import { orpc } from "@/utils/orpc";
|
|
4
|
+
{{/if}}
|
|
5
|
+
{{#if (eq api "trpc")}}
|
|
2
6
|
import { trpc } from "@/utils/trpc";
|
|
7
|
+
{{/if}}
|
|
3
8
|
import { useQuery } from "@tanstack/react-query";
|
|
4
9
|
import { useEffect } from "react";
|
|
5
10
|
import { useNavigate } from "react-router";
|
|
@@ -8,7 +13,12 @@ export default function Dashboard() {
|
|
|
8
13
|
const { data: session, isPending } = authClient.useSession();
|
|
9
14
|
const navigate = useNavigate();
|
|
10
15
|
|
|
16
|
+
{{#if (eq api "orpc")}}
|
|
17
|
+
const privateData = useQuery(orpc.privateData.queryOptions());
|
|
18
|
+
{{/if}}
|
|
19
|
+
{{#if (eq api "trpc")}}
|
|
11
20
|
const privateData = useQuery(trpc.privateData.queryOptions());
|
|
21
|
+
{{/if}}
|
|
12
22
|
|
|
13
23
|
useEffect(() => {
|
|
14
24
|
if (!session && !isPending) {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { authClient } from "@/lib/auth-client";
|
|
2
|
+
{{#if (eq api "orpc")}}
|
|
3
|
+
import { orpc } from "@/utils/orpc";
|
|
4
|
+
{{/if}}
|
|
5
|
+
{{#if (eq api "trpc")}}
|
|
2
6
|
import { trpc } from "@/utils/trpc";
|
|
7
|
+
{{/if}}
|
|
3
8
|
import { useQuery } from "@tanstack/react-query";
|
|
4
9
|
import { createFileRoute } from "@tanstack/react-router";
|
|
5
10
|
import { useEffect } from "react";
|
|
@@ -13,7 +18,12 @@ function RouteComponent() {
|
|
|
13
18
|
|
|
14
19
|
const navigate = Route.useNavigate();
|
|
15
20
|
|
|
21
|
+
{{#if (eq api "orpc")}}
|
|
22
|
+
const privateData = useQuery(orpc.privateData.queryOptions());
|
|
23
|
+
{{/if}}
|
|
24
|
+
{{#if (eq api "trpc")}}
|
|
16
25
|
const privateData = useQuery(trpc.privateData.queryOptions());
|
|
26
|
+
{{/if}}
|
|
17
27
|
|
|
18
28
|
useEffect(() => {
|
|
19
29
|
if (!session && !isPending) {
|