create-better-t-stack 2.15.2 → 2.16.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 +9 -12
- package/package.json +1 -1
- package/templates/api/orpc/native/utils/orpc.ts.hbs +3 -3
- package/templates/api/orpc/web/nuxt/app/plugins/orpc.ts.hbs +2 -2
- package/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs +3 -3
- package/templates/api/orpc/web/solid/src/utils/orpc.ts.hbs +2 -2
- package/templates/api/orpc/web/svelte/src/lib/orpc.ts.hbs +2 -2
- package/templates/auth/web/nuxt/app/components/SignInForm.vue +1 -1
- package/templates/auth/web/nuxt/app/components/SignUpForm.vue +1 -1
- package/templates/auth/web/react/next/src/components/sign-in-form.tsx +1 -1
- package/templates/auth/web/react/next/src/components/sign-up-form.tsx +1 -1
- package/templates/auth/web/react/react-router/src/components/sign-in-form.tsx +1 -1
- package/templates/auth/web/react/react-router/src/components/sign-up-form.tsx +1 -1
- package/templates/auth/web/react/tanstack-router/src/components/sign-in-form.tsx +1 -1
- package/templates/auth/web/react/tanstack-router/src/components/sign-up-form.tsx +1 -1
- package/templates/auth/web/react/tanstack-start/src/components/sign-in-form.tsx +1 -1
- package/templates/auth/web/react/tanstack-start/src/components/sign-up-form.tsx +1 -1
- package/templates/auth/web/solid/src/components/sign-in-form.tsx +1 -1
- package/templates/auth/web/solid/src/components/sign-up-form.tsx +1 -1
- package/templates/auth/web/svelte/src/components/SignInForm.svelte +1 -1
- package/templates/auth/web/svelte/src/components/SignUpForm.svelte +1 -1
- package/templates/examples/todo/native/nativewind/app/(drawer)/todos.tsx.hbs +4 -4
- package/templates/examples/todo/native/unistyles/app/(drawer)/todos.tsx.hbs +5 -5
- package/templates/examples/todo/web/react/next/src/app/todos/page.tsx.hbs +4 -4
- package/templates/examples/todo/web/react/react-router/src/routes/todos.tsx.hbs +4 -4
- package/templates/examples/todo/web/react/tanstack-router/src/routes/todos.tsx.hbs +4 -4
- package/templates/examples/todo/web/react/tanstack-start/src/routes/todos.tsx.hbs +5 -5
- package/templates/examples/todo/web/solid/src/routes/{todos.tsx → todos.tsx.hbs} +2 -2
- package/templates/examples/todo/web/svelte/src/routes/todos/+page.svelte.hbs +2 -42
- package/templates/frontend/react/tanstack-router/src/routes/__root.tsx.hbs +2 -2
package/dist/index.js
CHANGED
|
@@ -86,12 +86,9 @@ const dependencyVersionMap = {
|
|
|
86
86
|
"@ai-sdk/svelte": "^2.1.9",
|
|
87
87
|
"@ai-sdk/react": "^1.2.12",
|
|
88
88
|
"@prisma/extension-accelerate": "^1.3.0",
|
|
89
|
-
"@orpc/server": "^1.
|
|
90
|
-
"@orpc/client": "^1.
|
|
91
|
-
"@orpc/
|
|
92
|
-
"@orpc/solid-query": "^1.2.0",
|
|
93
|
-
"@orpc/vue-query": "^1.2.0",
|
|
94
|
-
"@orpc/svelte-query": "^1.2.0",
|
|
89
|
+
"@orpc/server": "^1.4.1",
|
|
90
|
+
"@orpc/client": "^1.4.1",
|
|
91
|
+
"@orpc/tanstack-query": "^1.4.1",
|
|
95
92
|
"@trpc/tanstack-react-query": "^11.0.0",
|
|
96
93
|
"@trpc/server": "^11.0.0",
|
|
97
94
|
"@trpc/client": "^11.0.0",
|
|
@@ -499,7 +496,7 @@ async function setupApi(config) {
|
|
|
499
496
|
if (hasReactWeb) {
|
|
500
497
|
if (api === "orpc") await addPackageDependency({
|
|
501
498
|
dependencies: [
|
|
502
|
-
"@orpc/
|
|
499
|
+
"@orpc/tanstack-query",
|
|
503
500
|
"@orpc/client",
|
|
504
501
|
"@orpc/server"
|
|
505
502
|
],
|
|
@@ -516,7 +513,7 @@ async function setupApi(config) {
|
|
|
516
513
|
} else if (hasNuxtWeb) {
|
|
517
514
|
if (api === "orpc") await addPackageDependency({
|
|
518
515
|
dependencies: [
|
|
519
|
-
"@orpc/
|
|
516
|
+
"@orpc/tanstack-query",
|
|
520
517
|
"@orpc/client",
|
|
521
518
|
"@orpc/server"
|
|
522
519
|
],
|
|
@@ -525,7 +522,7 @@ async function setupApi(config) {
|
|
|
525
522
|
} else if (hasSvelteWeb) {
|
|
526
523
|
if (api === "orpc") await addPackageDependency({
|
|
527
524
|
dependencies: [
|
|
528
|
-
"@orpc/
|
|
525
|
+
"@orpc/tanstack-query",
|
|
529
526
|
"@orpc/client",
|
|
530
527
|
"@orpc/server",
|
|
531
528
|
"@tanstack/svelte-query"
|
|
@@ -535,7 +532,7 @@ async function setupApi(config) {
|
|
|
535
532
|
} else if (hasSolidWeb) {
|
|
536
533
|
if (api === "orpc") await addPackageDependency({
|
|
537
534
|
dependencies: [
|
|
538
|
-
"@orpc/
|
|
535
|
+
"@orpc/tanstack-query",
|
|
539
536
|
"@orpc/client",
|
|
540
537
|
"@orpc/server",
|
|
541
538
|
"@tanstack/solid-query"
|
|
@@ -555,7 +552,7 @@ async function setupApi(config) {
|
|
|
555
552
|
});
|
|
556
553
|
else if (api === "orpc") await addPackageDependency({
|
|
557
554
|
dependencies: [
|
|
558
|
-
"@orpc/
|
|
555
|
+
"@orpc/tanstack-query",
|
|
559
556
|
"@orpc/client",
|
|
560
557
|
"@orpc/server"
|
|
561
558
|
],
|
|
@@ -3484,7 +3481,7 @@ function processAndValidateFlags(options, projectName) {
|
|
|
3484
3481
|
if (options.api) {
|
|
3485
3482
|
config.api = options.api;
|
|
3486
3483
|
if (options.api === "none") {
|
|
3487
|
-
if (options.examples && !(options.examples.length === 1 && options.examples[0] === "none")) {
|
|
3484
|
+
if (options.examples && !(options.examples.length === 1 && options.examples[0] === "none") && options.backend !== "convex") {
|
|
3488
3485
|
consola$1.fatal("Cannot use '--examples' when '--api' is set to 'none'. Please remove the --examples flag or choose an API type.");
|
|
3489
3486
|
process.exit(1);
|
|
3490
3487
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-better-t-stack",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"description": "A modern CLI tool for scaffolding end-to-end type-safe TypeScript projects with best practices and customizable configurations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createORPCClient } from "@orpc/client";
|
|
2
2
|
import { RPCLink } from "@orpc/client/fetch";
|
|
3
|
-
import {
|
|
4
|
-
import type { RouterUtils } from "@orpc/
|
|
3
|
+
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
|
4
|
+
import type { RouterUtils } from "@orpc/tanstack-query";
|
|
5
5
|
import type { RouterClient } from "@orpc/server";
|
|
6
6
|
import { QueryCache, QueryClient } from "@tanstack/react-query";
|
|
7
7
|
import { createContext, useContext } from "react";
|
|
@@ -36,7 +36,7 @@ export const link = new RPCLink({
|
|
|
36
36
|
|
|
37
37
|
export const client: RouterClient<typeof appRouter> = createORPCClient(link);
|
|
38
38
|
|
|
39
|
-
export const orpc =
|
|
39
|
+
export const orpc = createTanstackQueryUtils(client);
|
|
40
40
|
|
|
41
41
|
export const ORPCContext = createContext<ORPCReactUtils | undefined>(undefined);
|
|
42
42
|
|
|
@@ -3,7 +3,7 @@ import type { RouterClient } from '@orpc/server'
|
|
|
3
3
|
import type { appRouter } from "../../../server/src/routers/index";
|
|
4
4
|
import { createORPCClient } from '@orpc/client'
|
|
5
5
|
import { RPCLink } from '@orpc/client/fetch'
|
|
6
|
-
import {
|
|
6
|
+
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
|
7
7
|
|
|
8
8
|
export default defineNuxtPlugin(() => {
|
|
9
9
|
const config = useRuntimeConfig()
|
|
@@ -25,7 +25,7 @@ export default defineNuxtPlugin(() => {
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
const client: RouterClient<typeof appRouter> = createORPCClient(rpcLink)
|
|
28
|
-
const orpcUtils =
|
|
28
|
+
const orpcUtils = createTanstackQueryUtils(client)
|
|
29
29
|
|
|
30
30
|
return {
|
|
31
31
|
provide: {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createORPCClient } from "@orpc/client";
|
|
2
2
|
import { RPCLink } from "@orpc/client/fetch";
|
|
3
|
-
import {
|
|
3
|
+
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
|
4
4
|
import { QueryCache, QueryClient } from "@tanstack/react-query";
|
|
5
5
|
import { toast } from "sonner";
|
|
6
6
|
import type { appRouter } from "../../../server/src/routers/index";
|
|
7
7
|
import type { RouterClient } from "@orpc/server";
|
|
8
8
|
import { createContext, use } from 'react'
|
|
9
|
-
import type { RouterUtils } from '@orpc/
|
|
9
|
+
import type { RouterUtils } from '@orpc/tanstack-query'
|
|
10
10
|
|
|
11
11
|
type ORPCReactUtils = RouterUtils<RouterClient<typeof appRouter>>
|
|
12
12
|
|
|
@@ -43,7 +43,7 @@ export const link = new RPCLink({
|
|
|
43
43
|
|
|
44
44
|
export const client: RouterClient<typeof appRouter> = createORPCClient(link)
|
|
45
45
|
|
|
46
|
-
export const orpc =
|
|
46
|
+
export const orpc = createTanstackQueryUtils(client)
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
export const ORPCContext = createContext<ORPCReactUtils | undefined>(undefined)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createORPCClient } from "@orpc/client";
|
|
2
2
|
import { RPCLink } from "@orpc/client/fetch";
|
|
3
|
-
import {
|
|
3
|
+
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
|
4
4
|
import { QueryCache, QueryClient } from "@tanstack/solid-query";
|
|
5
5
|
import type { appRouter } from "../../../server/src/routers/index";
|
|
6
6
|
import type { RouterClient } from "@orpc/server";
|
|
@@ -27,4 +27,4 @@ export const link = new RPCLink({
|
|
|
27
27
|
|
|
28
28
|
export const client: RouterClient<typeof appRouter> = createORPCClient(link);
|
|
29
29
|
|
|
30
|
-
export const orpc =
|
|
30
|
+
export const orpc = createTanstackQueryUtils(client);
|
|
@@ -2,7 +2,7 @@ import { PUBLIC_SERVER_URL } from "$env/static/public";
|
|
|
2
2
|
import { createORPCClient } from "@orpc/client";
|
|
3
3
|
import { RPCLink } from "@orpc/client/fetch";
|
|
4
4
|
import type { RouterClient } from "@orpc/server";
|
|
5
|
-
import {
|
|
5
|
+
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
|
6
6
|
import { QueryCache, QueryClient } from "@tanstack/svelte-query";
|
|
7
7
|
import type { appRouter } from "../../../server/src/routers/index";
|
|
8
8
|
|
|
@@ -28,4 +28,4 @@ export const link = new RPCLink({
|
|
|
28
28
|
|
|
29
29
|
export const client: RouterClient<typeof appRouter> = createORPCClient(link);
|
|
30
30
|
|
|
31
|
-
export const orpc =
|
|
31
|
+
export const orpc = createTanstackQueryUtils(client);
|
|
@@ -9,7 +9,7 @@ const toast = useToast()
|
|
|
9
9
|
const loading = ref(false)
|
|
10
10
|
|
|
11
11
|
const schema = z.object({
|
|
12
|
-
email: z.
|
|
12
|
+
email: z.email('Invalid email address'),
|
|
13
13
|
password: z.string().min(8, 'Password must be at least 8 characters'),
|
|
14
14
|
})
|
|
15
15
|
|
|
@@ -10,7 +10,7 @@ const loading = ref(false)
|
|
|
10
10
|
|
|
11
11
|
const schema = z.object({
|
|
12
12
|
name: z.string().min(2, 'Name must be at least 2 characters'),
|
|
13
|
-
email: z.
|
|
13
|
+
email: z.email('Invalid email address'),
|
|
14
14
|
password: z.string().min(8, 'Password must be at least 8 characters'),
|
|
15
15
|
})
|
|
16
16
|
|
|
@@ -40,7 +40,7 @@ export default function SignInForm({
|
|
|
40
40
|
},
|
|
41
41
|
validators: {
|
|
42
42
|
onSubmit: z.object({
|
|
43
|
-
email: z.
|
|
43
|
+
email: z.email("Invalid email address"),
|
|
44
44
|
password: z.string().min(8, "Password must be at least 8 characters"),
|
|
45
45
|
}),
|
|
46
46
|
},
|
|
@@ -43,7 +43,7 @@ export default function SignUpForm({
|
|
|
43
43
|
validators: {
|
|
44
44
|
onSubmit: z.object({
|
|
45
45
|
name: z.string().min(2, "Name must be at least 2 characters"),
|
|
46
|
-
email: z.
|
|
46
|
+
email: z.email("Invalid email address"),
|
|
47
47
|
password: z.string().min(8, "Password must be at least 8 characters"),
|
|
48
48
|
}),
|
|
49
49
|
},
|
|
@@ -40,7 +40,7 @@ export default function SignInForm({
|
|
|
40
40
|
},
|
|
41
41
|
validators: {
|
|
42
42
|
onSubmit: z.object({
|
|
43
|
-
email: z.
|
|
43
|
+
email: z.email("Invalid email address"),
|
|
44
44
|
password: z.string().min(8, "Password must be at least 8 characters"),
|
|
45
45
|
}),
|
|
46
46
|
},
|
|
@@ -43,7 +43,7 @@ export default function SignUpForm({
|
|
|
43
43
|
validators: {
|
|
44
44
|
onSubmit: z.object({
|
|
45
45
|
name: z.string().min(2, "Name must be at least 2 characters"),
|
|
46
|
-
email: z.
|
|
46
|
+
email: z.email("Invalid email address"),
|
|
47
47
|
password: z.string().min(8, "Password must be at least 8 characters"),
|
|
48
48
|
}),
|
|
49
49
|
},
|
|
@@ -44,7 +44,7 @@ export default function SignInForm({
|
|
|
44
44
|
},
|
|
45
45
|
validators: {
|
|
46
46
|
onSubmit: z.object({
|
|
47
|
-
email: z.
|
|
47
|
+
email: z.email("Invalid email address"),
|
|
48
48
|
password: z.string().min(8, "Password must be at least 8 characters"),
|
|
49
49
|
}),
|
|
50
50
|
},
|
|
@@ -47,7 +47,7 @@ export default function SignUpForm({
|
|
|
47
47
|
validators: {
|
|
48
48
|
onSubmit: z.object({
|
|
49
49
|
name: z.string().min(2, "Name must be at least 2 characters"),
|
|
50
|
-
email: z.
|
|
50
|
+
email: z.email("Invalid email address"),
|
|
51
51
|
password: z.string().min(8, "Password must be at least 8 characters"),
|
|
52
52
|
}),
|
|
53
53
|
},
|
|
@@ -44,7 +44,7 @@ export default function SignInForm({
|
|
|
44
44
|
},
|
|
45
45
|
validators: {
|
|
46
46
|
onSubmit: z.object({
|
|
47
|
-
email: z.
|
|
47
|
+
email: z.email("Invalid email address"),
|
|
48
48
|
password: z.string().min(8, "Password must be at least 8 characters"),
|
|
49
49
|
}),
|
|
50
50
|
},
|
|
@@ -47,7 +47,7 @@ export default function SignUpForm({
|
|
|
47
47
|
validators: {
|
|
48
48
|
onSubmit: z.object({
|
|
49
49
|
name: z.string().min(2, "Name must be at least 2 characters"),
|
|
50
|
-
email: z.
|
|
50
|
+
email: z.email("Invalid email address"),
|
|
51
51
|
password: z.string().min(8, "Password must be at least 8 characters"),
|
|
52
52
|
}),
|
|
53
53
|
},
|
|
@@ -39,7 +39,7 @@ export default function SignInForm({
|
|
|
39
39
|
},
|
|
40
40
|
validators: {
|
|
41
41
|
onSubmit: z.object({
|
|
42
|
-
email: z.
|
|
42
|
+
email: z.email("Invalid email address"),
|
|
43
43
|
password: z.string().min(8, "Password must be at least 8 characters"),
|
|
44
44
|
}),
|
|
45
45
|
},
|
|
@@ -42,7 +42,7 @@ export default function SignUpForm({
|
|
|
42
42
|
validators: {
|
|
43
43
|
onSubmit: z.object({
|
|
44
44
|
name: z.string().min(2, "Name must be at least 2 characters"),
|
|
45
|
-
email: z.
|
|
45
|
+
email: z.email("Invalid email address"),
|
|
46
46
|
password: z.string().min(8, "Password must be at least 8 characters"),
|
|
47
47
|
}),
|
|
48
48
|
},
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
let { switchToSignUp } = $props<{ switchToSignUp: () => void }>();
|
|
8
8
|
|
|
9
9
|
const validationSchema = z.object({
|
|
10
|
-
email: z.
|
|
10
|
+
email: z.email('Invalid email address'),
|
|
11
11
|
password: z.string().min(1, 'Password is required'),
|
|
12
12
|
});
|
|
13
13
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
const validationSchema = z.object({
|
|
10
10
|
name: z.string().min(2, 'Name must be at least 2 characters'),
|
|
11
|
-
email: z.
|
|
11
|
+
email: z.email('Invalid email address'),
|
|
12
12
|
password: z.string().min(8, 'Password must be at least 8 characters'),
|
|
13
13
|
});
|
|
14
14
|
|
|
@@ -70,12 +70,12 @@ export default function TodosScreen() {
|
|
|
70
70
|
);
|
|
71
71
|
const toggleMutation = useMutation(
|
|
72
72
|
orpc.todo.toggle.mutationOptions({
|
|
73
|
-
onSuccess: () => todos.refetch(),
|
|
73
|
+
onSuccess: () => { todos.refetch() },
|
|
74
74
|
}),
|
|
75
75
|
);
|
|
76
76
|
const deleteMutation = useMutation(
|
|
77
77
|
orpc.todo.delete.mutationOptions({
|
|
78
|
-
onSuccess: () => todos.refetch(),
|
|
78
|
+
onSuccess: () => { todos.refetch() },
|
|
79
79
|
}),
|
|
80
80
|
);
|
|
81
81
|
{{/if}}
|
|
@@ -91,12 +91,12 @@ export default function TodosScreen() {
|
|
|
91
91
|
);
|
|
92
92
|
const toggleMutation = useMutation(
|
|
93
93
|
trpc.todo.toggle.mutationOptions({
|
|
94
|
-
onSuccess: () => todos.refetch(),
|
|
94
|
+
onSuccess: () => { todos.refetch() },
|
|
95
95
|
}),
|
|
96
96
|
);
|
|
97
97
|
const deleteMutation = useMutation(
|
|
98
98
|
trpc.todo.delete.mutationOptions({
|
|
99
|
-
onSuccess: () => todos.refetch(),
|
|
99
|
+
onSuccess: () => { todos.refetch() },
|
|
100
100
|
}),
|
|
101
101
|
);
|
|
102
102
|
{{/if}}
|
|
@@ -73,12 +73,12 @@ export default function TodosScreen() {
|
|
|
73
73
|
);
|
|
74
74
|
const toggleMutation = useMutation(
|
|
75
75
|
orpc.todo.toggle.mutationOptions({
|
|
76
|
-
onSuccess: () => todos.refetch(),
|
|
76
|
+
onSuccess: () => { todos.refetch() },
|
|
77
77
|
})
|
|
78
78
|
);
|
|
79
79
|
const deleteMutation = useMutation(
|
|
80
80
|
orpc.todo.delete.mutationOptions({
|
|
81
|
-
onSuccess: () => todos.refetch(),
|
|
81
|
+
onSuccess: () => { todos.refetch() },
|
|
82
82
|
})
|
|
83
83
|
);
|
|
84
84
|
{{/if}}
|
|
@@ -94,12 +94,12 @@ export default function TodosScreen() {
|
|
|
94
94
|
);
|
|
95
95
|
const toggleMutation = useMutation(
|
|
96
96
|
trpc.todo.toggle.mutationOptions({
|
|
97
|
-
onSuccess: () => todos.refetch(),
|
|
97
|
+
onSuccess: () => { todos.refetch() },
|
|
98
98
|
})
|
|
99
99
|
);
|
|
100
100
|
const deleteMutation = useMutation(
|
|
101
101
|
trpc.todo.delete.mutationOptions({
|
|
102
|
-
onSuccess: () => todos.refetch(),
|
|
102
|
+
onSuccess: () => { todos.refetch() },
|
|
103
103
|
})
|
|
104
104
|
);
|
|
105
105
|
{{/if}}
|
|
@@ -337,4 +337,4 @@ const styles = StyleSheet.create((theme) => ({
|
|
|
337
337
|
textDecorationLine: "line-through",
|
|
338
338
|
color: theme.colors.border,
|
|
339
339
|
},
|
|
340
|
-
}));
|
|
340
|
+
}));
|
|
@@ -65,12 +65,12 @@ export default function TodosPage() {
|
|
|
65
65
|
);
|
|
66
66
|
const toggleMutation = useMutation(
|
|
67
67
|
orpc.todo.toggle.mutationOptions({
|
|
68
|
-
onSuccess: () => todos.refetch(),
|
|
68
|
+
onSuccess: () => { todos.refetch() },
|
|
69
69
|
}),
|
|
70
70
|
);
|
|
71
71
|
const deleteMutation = useMutation(
|
|
72
72
|
orpc.todo.delete.mutationOptions({
|
|
73
|
-
onSuccess: () => todos.refetch(),
|
|
73
|
+
onSuccess: () => { todos.refetch() },
|
|
74
74
|
}),
|
|
75
75
|
);
|
|
76
76
|
{{/if}}
|
|
@@ -86,12 +86,12 @@ export default function TodosPage() {
|
|
|
86
86
|
);
|
|
87
87
|
const toggleMutation = useMutation(
|
|
88
88
|
trpc.todo.toggle.mutationOptions({
|
|
89
|
-
onSuccess: () => todos.refetch(),
|
|
89
|
+
onSuccess: () => { todos.refetch() },
|
|
90
90
|
}),
|
|
91
91
|
);
|
|
92
92
|
const deleteMutation = useMutation(
|
|
93
93
|
trpc.todo.delete.mutationOptions({
|
|
94
|
-
onSuccess: () => todos.refetch(),
|
|
94
|
+
onSuccess: () => { todos.refetch() },
|
|
95
95
|
}),
|
|
96
96
|
);
|
|
97
97
|
{{/if}}
|
|
@@ -62,12 +62,12 @@ export default function Todos() {
|
|
|
62
62
|
);
|
|
63
63
|
const toggleMutation = useMutation(
|
|
64
64
|
orpc.todo.toggle.mutationOptions({
|
|
65
|
-
onSuccess: () => todos.refetch(),
|
|
65
|
+
onSuccess: () => { todos.refetch() },
|
|
66
66
|
})
|
|
67
67
|
);
|
|
68
68
|
const deleteMutation = useMutation(
|
|
69
69
|
orpc.todo.delete.mutationOptions({
|
|
70
|
-
onSuccess: () => todos.refetch(),
|
|
70
|
+
onSuccess: () => { todos.refetch() },
|
|
71
71
|
})
|
|
72
72
|
);
|
|
73
73
|
{{/if}}
|
|
@@ -83,12 +83,12 @@ export default function Todos() {
|
|
|
83
83
|
);
|
|
84
84
|
const toggleMutation = useMutation(
|
|
85
85
|
trpc.todo.toggle.mutationOptions({
|
|
86
|
-
onSuccess: () => todos.refetch(),
|
|
86
|
+
onSuccess: () => { todos.refetch() },
|
|
87
87
|
})
|
|
88
88
|
);
|
|
89
89
|
const deleteMutation = useMutation(
|
|
90
90
|
trpc.todo.delete.mutationOptions({
|
|
91
|
-
onSuccess: () => todos.refetch(),
|
|
91
|
+
onSuccess: () => { todos.refetch() },
|
|
92
92
|
})
|
|
93
93
|
);
|
|
94
94
|
{{/if}}
|
|
@@ -67,12 +67,12 @@ function TodosRoute() {
|
|
|
67
67
|
);
|
|
68
68
|
const toggleMutation = useMutation(
|
|
69
69
|
orpc.todo.toggle.mutationOptions({
|
|
70
|
-
onSuccess: () => todos.refetch(),
|
|
70
|
+
onSuccess: () => { todos.refetch() },
|
|
71
71
|
}),
|
|
72
72
|
);
|
|
73
73
|
const deleteMutation = useMutation(
|
|
74
74
|
orpc.todo.delete.mutationOptions({
|
|
75
|
-
onSuccess: () => todos.refetch(),
|
|
75
|
+
onSuccess: () => { todos.refetch() },
|
|
76
76
|
}),
|
|
77
77
|
);
|
|
78
78
|
{{/if}}
|
|
@@ -88,12 +88,12 @@ function TodosRoute() {
|
|
|
88
88
|
);
|
|
89
89
|
const toggleMutation = useMutation(
|
|
90
90
|
trpc.todo.toggle.mutationOptions({
|
|
91
|
-
onSuccess: () => todos.refetch(),
|
|
91
|
+
onSuccess: () => { todos.refetch() },
|
|
92
92
|
}),
|
|
93
93
|
);
|
|
94
94
|
const deleteMutation = useMutation(
|
|
95
95
|
trpc.todo.delete.mutationOptions({
|
|
96
|
-
onSuccess: () => todos.refetch(),
|
|
96
|
+
onSuccess: () => { todos.refetch() },
|
|
97
97
|
}),
|
|
98
98
|
);
|
|
99
99
|
{{/if}}
|
|
@@ -17,7 +17,7 @@ import { useSuspenseQuery } from "@tanstack/react-query";
|
|
|
17
17
|
import { convexQuery } from "@convex-dev/react-query";
|
|
18
18
|
import { useMutation } from "convex/react";
|
|
19
19
|
import { api } from "@{{projectName}}/backend/convex/_generated/api";
|
|
20
|
-
import type { Id } from "@{{projectName}}/backend/convex/_generated/dataModel
|
|
20
|
+
import type { Id } from "@{{projectName}}/backend/convex/_generated/dataModel";
|
|
21
21
|
{{else}}
|
|
22
22
|
{{#if (eq api "trpc")}}
|
|
23
23
|
import { useTRPC } from "@/utils/trpc";
|
|
@@ -92,12 +92,12 @@ function TodosRoute() {
|
|
|
92
92
|
);
|
|
93
93
|
const toggleMutation = useMutation(
|
|
94
94
|
trpc.todo.toggle.mutationOptions({
|
|
95
|
-
onSuccess: () => todos.refetch(),
|
|
95
|
+
onSuccess: () => { todos.refetch() },
|
|
96
96
|
}),
|
|
97
97
|
);
|
|
98
98
|
const deleteMutation = useMutation(
|
|
99
99
|
trpc.todo.delete.mutationOptions({
|
|
100
|
-
onSuccess: () => todos.refetch(),
|
|
100
|
+
onSuccess: () => { todos.refetch() },
|
|
101
101
|
}),
|
|
102
102
|
);
|
|
103
103
|
{{/if}}
|
|
@@ -113,12 +113,12 @@ function TodosRoute() {
|
|
|
113
113
|
);
|
|
114
114
|
const toggleMutation = useMutation(
|
|
115
115
|
orpc.todo.toggle.mutationOptions({
|
|
116
|
-
onSuccess: () => todos.refetch(),
|
|
116
|
+
onSuccess: () => { todos.refetch() },
|
|
117
117
|
}),
|
|
118
118
|
);
|
|
119
119
|
const deleteMutation = useMutation(
|
|
120
120
|
orpc.todo.delete.mutationOptions({
|
|
121
|
-
onSuccess: () => todos.refetch(),
|
|
121
|
+
onSuccess: () => { todos.refetch() },
|
|
122
122
|
}),
|
|
123
123
|
);
|
|
124
124
|
{{/if}}
|
|
@@ -24,13 +24,13 @@ function TodosRoute() {
|
|
|
24
24
|
|
|
25
25
|
const toggleMutation = useMutation(() =>
|
|
26
26
|
orpc.todo.toggle.mutationOptions({
|
|
27
|
-
onSuccess: () => todos.refetch(),
|
|
27
|
+
onSuccess: () => { todos.refetch() },
|
|
28
28
|
}),
|
|
29
29
|
);
|
|
30
30
|
|
|
31
31
|
const deleteMutation = useMutation(() =>
|
|
32
32
|
orpc.todo.delete.mutationOptions({
|
|
33
|
-
onSuccess: () => todos.refetch(),
|
|
33
|
+
onSuccess: () => { todos.refetch() },
|
|
34
34
|
}),
|
|
35
35
|
);
|
|
36
36
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<script lang="ts">
|
|
3
3
|
import { useQuery, useConvexClient } from 'convex-svelte';
|
|
4
4
|
import { api } from '@{{projectName}}/backend/convex/_generated/api';
|
|
5
|
-
import type { Id } from '@{{projectName}}/backend/convex/_generated/dataModel
|
|
5
|
+
import type { Id } from '@{{projectName}}/backend/convex/_generated/dataModel';
|
|
6
6
|
|
|
7
7
|
let newTodoText = $state('');
|
|
8
8
|
let isAdding = $state(false);
|
|
@@ -164,9 +164,6 @@
|
|
|
164
164
|
{{#if (eq api "orpc")}}
|
|
165
165
|
import { orpc } from '$lib/orpc';
|
|
166
166
|
{{/if}}
|
|
167
|
-
{{#if (eq api "trpc")}}
|
|
168
|
-
import { trpc } from '$lib/trpc';
|
|
169
|
-
{{/if}}
|
|
170
167
|
import { createQuery, createMutation } from '@tanstack/svelte-query';
|
|
171
168
|
|
|
172
169
|
let newTodoText = $state('');
|
|
@@ -208,43 +205,6 @@
|
|
|
208
205
|
})
|
|
209
206
|
);
|
|
210
207
|
{{/if}}
|
|
211
|
-
{{#if (eq api "trpc")}}
|
|
212
|
-
const todosQuery = createQuery(trpc.todo.getAll.queryOptions());
|
|
213
|
-
|
|
214
|
-
const addMutation = createMutation(
|
|
215
|
-
trpc.todo.create.mutationOptions({
|
|
216
|
-
onSuccess: () => {
|
|
217
|
-
$todosQuery.refetch();
|
|
218
|
-
newTodoText = '';
|
|
219
|
-
},
|
|
220
|
-
onError: (error) => {
|
|
221
|
-
console.error('Failed to create todo:', error?.message ?? error);
|
|
222
|
-
},
|
|
223
|
-
})
|
|
224
|
-
);
|
|
225
|
-
|
|
226
|
-
const toggleMutation = createMutation(
|
|
227
|
-
trpc.todo.toggle.mutationOptions({
|
|
228
|
-
onSuccess: () => {
|
|
229
|
-
$todosQuery.refetch();
|
|
230
|
-
},
|
|
231
|
-
onError: (error) => {
|
|
232
|
-
console.error('Failed to toggle todo:', error?.message ?? error);
|
|
233
|
-
},
|
|
234
|
-
})
|
|
235
|
-
);
|
|
236
|
-
|
|
237
|
-
const deleteMutation = createMutation(
|
|
238
|
-
trpc.todo.delete.mutationOptions({
|
|
239
|
-
onSuccess: () => {
|
|
240
|
-
$todosQuery.refetch();
|
|
241
|
-
},
|
|
242
|
-
onError: (error) => {
|
|
243
|
-
console.error('Failed to delete todo:', error?.message ?? error);
|
|
244
|
-
},
|
|
245
|
-
})
|
|
246
|
-
);
|
|
247
|
-
{{/if}}
|
|
248
208
|
|
|
249
209
|
function handleAddTodo(event: SubmitEvent) {
|
|
250
210
|
event.preventDefault();
|
|
@@ -271,7 +231,7 @@
|
|
|
271
231
|
</script>
|
|
272
232
|
|
|
273
233
|
<div class="p-4">
|
|
274
|
-
<h1 class="text-xl mb-4">Todos{{#if (eq api "
|
|
234
|
+
<h1 class="text-xl mb-4">Todos{{#if (eq api "orpc")}} (oRPC){{/if}}</h1>
|
|
275
235
|
|
|
276
236
|
<form onsubmit={handleAddTodo} class="flex gap-2 mb-4">
|
|
277
237
|
<input
|
|
@@ -8,7 +8,7 @@ import type { QueryClient } from "@tanstack/react-query";
|
|
|
8
8
|
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
|
9
9
|
import { useState } from "react";
|
|
10
10
|
import type { RouterClient } from "@orpc/server";
|
|
11
|
-
import {
|
|
11
|
+
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
|
12
12
|
import type { appRouter } from "../../../server/src/routers";
|
|
13
13
|
import { createORPCClient } from "@orpc/client";
|
|
14
14
|
{{/if}}
|
|
@@ -68,7 +68,7 @@ function RootComponent() {
|
|
|
68
68
|
|
|
69
69
|
{{#if (eq api "orpc")}}
|
|
70
70
|
const [client] = useState<RouterClient<typeof appRouter>>(() => createORPCClient(link));
|
|
71
|
-
const [orpcUtils] = useState(() =>
|
|
71
|
+
const [orpcUtils] = useState(() => createTanstackQueryUtils(client));
|
|
72
72
|
{{/if}}
|
|
73
73
|
|
|
74
74
|
return (
|