create-better-t-stack 3.0.12-canary.b6015ca7 → 3.1.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/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{src-DnZjYQ_z.js → src-3Gylwm4_.js} +15 -12
- package/package.json +1 -1
- package/templates/api/orpc/fullstack/next/src/app/api/rpc/[[...rest]]/route.ts.hbs +1 -1
- package/templates/api/orpc/fullstack/tanstack-start/src/routes/api/rpc/$.ts.hbs +1 -1
- package/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs +30 -56
- package/templates/backend/server/elysia/src/index.ts.hbs +1 -1
- package/templates/backend/server/express/src/index.ts.hbs +1 -1
- package/templates/backend/server/fastify/src/index.ts.hbs +1 -1
- package/templates/backend/server/hono/src/index.ts.hbs +1 -1
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1388,7 +1388,7 @@ const getLatestCLIVersion = () => {
|
|
|
1388
1388
|
*/
|
|
1389
1389
|
function isTelemetryEnabled() {
|
|
1390
1390
|
const BTS_TELEMETRY_DISABLED = process.env.BTS_TELEMETRY_DISABLED;
|
|
1391
|
-
const BTS_TELEMETRY = "
|
|
1391
|
+
const BTS_TELEMETRY = "1";
|
|
1392
1392
|
if (BTS_TELEMETRY_DISABLED !== void 0) return BTS_TELEMETRY_DISABLED !== "1";
|
|
1393
1393
|
if (BTS_TELEMETRY !== void 0) return BTS_TELEMETRY === "1";
|
|
1394
1394
|
return true;
|
|
@@ -1396,8 +1396,8 @@ function isTelemetryEnabled() {
|
|
|
1396
1396
|
|
|
1397
1397
|
//#endregion
|
|
1398
1398
|
//#region src/utils/analytics.ts
|
|
1399
|
-
const POSTHOG_API_KEY = "
|
|
1400
|
-
const POSTHOG_HOST = "
|
|
1399
|
+
const POSTHOG_API_KEY = "phc_8ZUxEwwfKMajJLvxz1daGd931dYbQrwKNficBmsdIrs";
|
|
1400
|
+
const POSTHOG_HOST = "https://us.i.posthog.com";
|
|
1401
1401
|
function generateSessionId() {
|
|
1402
1402
|
const rand = Math.random().toString(36).slice(2);
|
|
1403
1403
|
return `cli_${Date.now().toString(36)}${rand}`;
|
|
@@ -4034,10 +4034,6 @@ async function setupBetterAuthPlugins(projectDir, config) {
|
|
|
4034
4034
|
}
|
|
4035
4035
|
authIndexFile.save();
|
|
4036
4036
|
}
|
|
4037
|
-
async function setupBetterAuthPluginsForSelfBackend(projectDir, config) {
|
|
4038
|
-
if (config.backend !== "self" || config.auth !== "better-auth") return;
|
|
4039
|
-
await setupBetterAuthPlugins(projectDir, config);
|
|
4040
|
-
}
|
|
4041
4037
|
|
|
4042
4038
|
//#endregion
|
|
4043
4039
|
//#region src/utils/setup-catalogs.ts
|
|
@@ -4238,7 +4234,11 @@ function getApiDependencies(api, frontendType) {
|
|
|
4238
4234
|
] };
|
|
4239
4235
|
else if (api === "trpc") deps.server = { dependencies: ["@trpc/server", "@trpc/client"] };
|
|
4240
4236
|
if (frontendType.hasReactWeb) {
|
|
4241
|
-
if (api === "orpc") deps.web = { dependencies: [
|
|
4237
|
+
if (api === "orpc") deps.web = { dependencies: [
|
|
4238
|
+
"@orpc/tanstack-query",
|
|
4239
|
+
"@orpc/client",
|
|
4240
|
+
"@orpc/server"
|
|
4241
|
+
] };
|
|
4242
4242
|
else if (api === "trpc") deps.web = { dependencies: [
|
|
4243
4243
|
"@trpc/tanstack-react-query",
|
|
4244
4244
|
"@trpc/client",
|
|
@@ -4248,7 +4248,8 @@ function getApiDependencies(api, frontendType) {
|
|
|
4248
4248
|
dependencies: [
|
|
4249
4249
|
"@tanstack/vue-query",
|
|
4250
4250
|
"@orpc/tanstack-query",
|
|
4251
|
-
"@orpc/client"
|
|
4251
|
+
"@orpc/client",
|
|
4252
|
+
"@orpc/server"
|
|
4252
4253
|
],
|
|
4253
4254
|
devDependencies: ["@tanstack/vue-query-devtools"]
|
|
4254
4255
|
};
|
|
@@ -4256,6 +4257,7 @@ function getApiDependencies(api, frontendType) {
|
|
|
4256
4257
|
dependencies: [
|
|
4257
4258
|
"@orpc/tanstack-query",
|
|
4258
4259
|
"@orpc/client",
|
|
4260
|
+
"@orpc/server",
|
|
4259
4261
|
"@tanstack/svelte-query"
|
|
4260
4262
|
],
|
|
4261
4263
|
devDependencies: ["@tanstack/svelte-query-devtools"]
|
|
@@ -4264,6 +4266,7 @@ function getApiDependencies(api, frontendType) {
|
|
|
4264
4266
|
dependencies: [
|
|
4265
4267
|
"@orpc/tanstack-query",
|
|
4266
4268
|
"@orpc/client",
|
|
4269
|
+
"@orpc/server",
|
|
4267
4270
|
"@tanstack/solid-query"
|
|
4268
4271
|
],
|
|
4269
4272
|
devDependencies: ["@tanstack/solid-query-devtools", "@tanstack/solid-router-devtools"]
|
|
@@ -6490,9 +6493,9 @@ async function displayPostInstallInstructions(config) {
|
|
|
6490
6493
|
else if (!hasNative && !addons?.includes("starlight")) output += `${pc.yellow("NOTE:")} You are creating a backend-only app\n (no frontend selected)\n`;
|
|
6491
6494
|
if (!isConvex && !isBackendSelf) {
|
|
6492
6495
|
output += `${pc.cyan("•")} Backend API: http://localhost:3000\n`;
|
|
6493
|
-
if (api === "orpc") output += `${pc.cyan("•")} OpenAPI (Scalar UI): http://localhost:3000/api\n`;
|
|
6496
|
+
if (api === "orpc") output += `${pc.cyan("•")} OpenAPI (Scalar UI): http://localhost:3000/api-reference\n`;
|
|
6494
6497
|
}
|
|
6495
|
-
if (isBackendSelf && api === "orpc") output += `${pc.cyan("•")} OpenAPI (Scalar UI): http://localhost:${webPort}/rpc/api\n`;
|
|
6498
|
+
if (isBackendSelf && api === "orpc") output += `${pc.cyan("•")} OpenAPI (Scalar UI): http://localhost:${webPort}/api/rpc/api-reference\n`;
|
|
6496
6499
|
if (addons?.includes("starlight")) output += `${pc.cyan("•")} Docs: http://localhost:4321\n`;
|
|
6497
6500
|
if (addons?.includes("fumadocs")) output += `${pc.cyan("•")} Fumadocs: http://localhost:4000\n`;
|
|
6498
6501
|
if (nativeInstructions) output += `\n${nativeInstructions.trim()}\n`;
|
|
@@ -6940,7 +6943,7 @@ async function createProject(options, cliInput) {
|
|
|
6940
6943
|
}
|
|
6941
6944
|
if (options.addons.length > 0 && options.addons[0] !== "none") await setupAddons(options);
|
|
6942
6945
|
if (options.auth && options.auth !== "none") await setupAuth(options);
|
|
6943
|
-
await
|
|
6946
|
+
await setupBetterAuthPlugins(projectDir, options);
|
|
6944
6947
|
if (options.payments && options.payments !== "none") await setupPayments(options);
|
|
6945
6948
|
await handleExtras(projectDir, options);
|
|
6946
6949
|
await setupEnvironmentVariables(options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-better-t-stack",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.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",
|
|
@@ -35,7 +35,7 @@ async function handleRequest(req: NextRequest) {
|
|
|
35
35
|
if (rpcResult.response) return rpcResult.response;
|
|
36
36
|
|
|
37
37
|
const apiResult = await apiHandler.handle(req, {
|
|
38
|
-
prefix: "/api/rpc/api",
|
|
38
|
+
prefix: "/api/rpc/api-reference",
|
|
39
39
|
context: await createContext(req),
|
|
40
40
|
});
|
|
41
41
|
if (apiResult.response) return apiResult.response;
|
|
@@ -36,7 +36,7 @@ async function handle({ request }: { request: Request }) {
|
|
|
36
36
|
if (rpcResult.response) return rpcResult.response;
|
|
37
37
|
|
|
38
38
|
const apiResult = await apiHandler.handle(request, {
|
|
39
|
-
prefix: "/api/rpc/api",
|
|
39
|
+
prefix: "/api/rpc/api-reference",
|
|
40
40
|
context: await createContext({ req: request }),
|
|
41
41
|
});
|
|
42
42
|
if (apiResult.response) return apiResult.response;
|
|
@@ -3,10 +3,14 @@ import { RPCLink } from "@orpc/client/fetch";
|
|
|
3
3
|
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
|
4
4
|
import { QueryCache, QueryClient } from "@tanstack/react-query";
|
|
5
5
|
import { toast } from "sonner";
|
|
6
|
-
import type { AppRouterClient } from "@{{projectName}}/api/routers/index";
|
|
7
6
|
{{#if (includes frontend "tanstack-start")}}
|
|
7
|
+
import { createRouterClient } from "@orpc/server";
|
|
8
|
+
import type { RouterClient } from "@orpc/server";
|
|
8
9
|
import { createIsomorphicFn } from "@tanstack/react-start";
|
|
9
|
-
import {
|
|
10
|
+
import { appRouter } from "@{{projectName}}/api/routers/index";
|
|
11
|
+
import { createContext } from "@{{projectName}}/api/context";
|
|
12
|
+
{{else}}
|
|
13
|
+
import type { AppRouterClient } from "@{{projectName}}/api/routers/index";
|
|
10
14
|
{{/if}}
|
|
11
15
|
|
|
12
16
|
export const queryClient = new QueryClient({
|
|
@@ -25,61 +29,31 @@ export const queryClient = new QueryClient({
|
|
|
25
29
|
});
|
|
26
30
|
|
|
27
31
|
{{#if (includes frontend "tanstack-start")}}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
credentials: "include",
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
{{/if}}
|
|
52
|
-
}));
|
|
32
|
+
const getORPCClient = createIsomorphicFn()
|
|
33
|
+
.server(() =>
|
|
34
|
+
createRouterClient(appRouter, {
|
|
35
|
+
context: async ({ req }) => {
|
|
36
|
+
return createContext({ req });
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
)
|
|
40
|
+
.client((): RouterClient<typeof appRouter> => {
|
|
41
|
+
const link = new RPCLink({
|
|
42
|
+
url: {{#if (eq backend "self")}}`${window.location.origin}/api/rpc`{{else}}`${import.meta.env.VITE_SERVER_URL}/rpc`{{/if}},
|
|
43
|
+
{{#if (eq auth "better-auth")}}
|
|
44
|
+
fetch(url, options) {
|
|
45
|
+
return fetch(url, {
|
|
46
|
+
...options,
|
|
47
|
+
credentials: "include",
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
{{/if}}
|
|
51
|
+
});
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const getClientLink = createIsomorphicFn()
|
|
57
|
-
.client(() => new RPCLink({
|
|
58
|
-
url: `${window.location.origin}/api/rpc`,
|
|
59
|
-
{{#if (eq auth "better-auth")}}
|
|
60
|
-
fetch(url, options) {
|
|
61
|
-
return fetch(url, {
|
|
62
|
-
...options,
|
|
63
|
-
credentials: "include",
|
|
64
|
-
});
|
|
65
|
-
},
|
|
66
|
-
{{/if}}
|
|
67
|
-
}))
|
|
68
|
-
.server(() => new RPCLink({
|
|
69
|
-
url: `${import.meta.env.VITE_SERVER_URL}/rpc`,
|
|
70
|
-
{{#if (eq auth "better-auth")}}
|
|
71
|
-
headers: () => getRequestHeaders(),
|
|
72
|
-
fetch(url, options) {
|
|
73
|
-
return fetch(url, {
|
|
74
|
-
...options,
|
|
75
|
-
credentials: "include",
|
|
76
|
-
});
|
|
77
|
-
},
|
|
78
|
-
{{/if}}
|
|
79
|
-
}));
|
|
53
|
+
return createORPCClient(link);
|
|
54
|
+
});
|
|
80
55
|
|
|
81
|
-
export const
|
|
82
|
-
{{/if}}
|
|
56
|
+
export const client: RouterClient<typeof appRouter> = getORPCClient();
|
|
83
57
|
{{else}}
|
|
84
58
|
export const link = new RPCLink({
|
|
85
59
|
{{#if (and (eq backend "self") (includes frontend "next"))}}
|
|
@@ -108,8 +82,8 @@ export const link = new RPCLink({
|
|
|
108
82
|
{{/if}}
|
|
109
83
|
{{/if}}
|
|
110
84
|
});
|
|
111
|
-
{{/if}}
|
|
112
85
|
|
|
113
86
|
export const client: AppRouterClient = createORPCClient(link)
|
|
87
|
+
{{/if}}
|
|
114
88
|
|
|
115
89
|
export const orpc = createTanstackQueryUtils(client)
|
|
@@ -82,7 +82,7 @@ const app = new Elysia()
|
|
|
82
82
|
})
|
|
83
83
|
.all('/api*', async (context) => {
|
|
84
84
|
const { response } = await apiHandler.handle(context.request, {
|
|
85
|
-
prefix: '/api',
|
|
85
|
+
prefix: '/api-reference',
|
|
86
86
|
context: await createContext({ context })
|
|
87
87
|
})
|
|
88
88
|
return response ?? new Response('Not Found', { status: 404 })
|
|
@@ -86,7 +86,7 @@ app.use(async (req, res, next) => {
|
|
|
86
86
|
if (rpcResult.matched) return;
|
|
87
87
|
|
|
88
88
|
const apiResult = await apiHandler.handle(req, res, {
|
|
89
|
-
prefix: "/api",
|
|
89
|
+
prefix: "/api-reference",
|
|
90
90
|
{{#if (eq auth "better-auth")}}
|
|
91
91
|
context: await createContext({ req }),
|
|
92
92
|
{{else}}
|