create-better-t-stack 3.0.12-canary.8a7c5ccb → 3.0.12-canary.b6015ca7
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-Defz5E7A.js → src-DnZjYQ_z.js} +27 -21
- package/package.json +1 -1
- package/templates/examples/ai/fullstack/tanstack-start/src/routes/api/ai/$.ts.hbs +31 -0
- package/templates/examples/ai/web/react/tanstack-start/src/routes/ai.tsx.hbs +1 -1
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -6627,28 +6627,34 @@ async function setupWorkspaceDependencies(projectDir, options) {
|
|
|
6627
6627
|
projectDir: dbPackageDir
|
|
6628
6628
|
});
|
|
6629
6629
|
const authPackageDir = path.join(projectDir, "packages/auth");
|
|
6630
|
-
if (await fs.pathExists(authPackageDir))
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6630
|
+
if (await fs.pathExists(authPackageDir)) {
|
|
6631
|
+
const authDeps = {};
|
|
6632
|
+
if (options.database !== "none" && await fs.pathExists(dbPackageDir)) authDeps[`@${projectName}/db`] = workspaceVersion;
|
|
6633
|
+
await addPackageDependency({
|
|
6634
|
+
dependencies: commonDeps,
|
|
6635
|
+
devDependencies: commonDevDeps,
|
|
6636
|
+
customDependencies: authDeps,
|
|
6637
|
+
projectDir: authPackageDir
|
|
6638
|
+
});
|
|
6639
|
+
}
|
|
6636
6640
|
const apiPackageDir = path.join(projectDir, "packages/api");
|
|
6637
|
-
if (await fs.pathExists(apiPackageDir))
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6641
|
+
if (await fs.pathExists(apiPackageDir)) {
|
|
6642
|
+
const apiDeps = {};
|
|
6643
|
+
if (options.auth !== "none" && await fs.pathExists(authPackageDir)) apiDeps[`@${projectName}/auth`] = workspaceVersion;
|
|
6644
|
+
if (options.database !== "none" && await fs.pathExists(dbPackageDir)) apiDeps[`@${projectName}/db`] = workspaceVersion;
|
|
6645
|
+
await addPackageDependency({
|
|
6646
|
+
dependencies: commonDeps,
|
|
6647
|
+
devDependencies: commonDevDeps,
|
|
6648
|
+
customDependencies: apiDeps,
|
|
6649
|
+
projectDir: apiPackageDir
|
|
6650
|
+
});
|
|
6651
|
+
}
|
|
6646
6652
|
const serverPackageDir = path.join(projectDir, "apps/server");
|
|
6647
6653
|
if (await fs.pathExists(serverPackageDir)) {
|
|
6648
6654
|
const serverDeps = {};
|
|
6649
|
-
if (await fs.pathExists(apiPackageDir)) serverDeps[`@${projectName}/api`] = workspaceVersion;
|
|
6650
|
-
if (await fs.pathExists(authPackageDir)) serverDeps[`@${projectName}/auth`] = workspaceVersion;
|
|
6651
|
-
if (await fs.pathExists(dbPackageDir)) serverDeps[`@${projectName}/db`] = workspaceVersion;
|
|
6655
|
+
if (options.api !== "none" && await fs.pathExists(apiPackageDir)) serverDeps[`@${projectName}/api`] = workspaceVersion;
|
|
6656
|
+
if (options.auth !== "none" && await fs.pathExists(authPackageDir)) serverDeps[`@${projectName}/auth`] = workspaceVersion;
|
|
6657
|
+
if (options.database !== "none" && await fs.pathExists(dbPackageDir)) serverDeps[`@${projectName}/db`] = workspaceVersion;
|
|
6652
6658
|
await addPackageDependency({
|
|
6653
6659
|
dependencies: commonDeps,
|
|
6654
6660
|
devDependencies: commonDevDeps,
|
|
@@ -6659,8 +6665,8 @@ async function setupWorkspaceDependencies(projectDir, options) {
|
|
|
6659
6665
|
const webPackageDir = path.join(projectDir, "apps/web");
|
|
6660
6666
|
if (await fs.pathExists(webPackageDir)) {
|
|
6661
6667
|
const webDeps = {};
|
|
6662
|
-
if (await fs.pathExists(apiPackageDir)) webDeps[`@${projectName}/api`] = workspaceVersion;
|
|
6663
|
-
if (await fs.pathExists(authPackageDir)) webDeps[`@${projectName}/auth`] = workspaceVersion;
|
|
6668
|
+
if (options.api !== "none" && await fs.pathExists(apiPackageDir)) webDeps[`@${projectName}/api`] = workspaceVersion;
|
|
6669
|
+
if (options.auth !== "none" && await fs.pathExists(authPackageDir)) webDeps[`@${projectName}/auth`] = workspaceVersion;
|
|
6664
6670
|
if (Object.keys(webDeps).length > 0) await addPackageDependency({
|
|
6665
6671
|
customDependencies: webDeps,
|
|
6666
6672
|
projectDir: webPackageDir
|
|
@@ -6669,7 +6675,7 @@ async function setupWorkspaceDependencies(projectDir, options) {
|
|
|
6669
6675
|
const nativePackageDir = path.join(projectDir, "apps/native");
|
|
6670
6676
|
if (await fs.pathExists(nativePackageDir)) {
|
|
6671
6677
|
const nativeDeps = {};
|
|
6672
|
-
if (await fs.pathExists(apiPackageDir)) nativeDeps[`@${projectName}/api`] = workspaceVersion;
|
|
6678
|
+
if (options.api !== "none" && await fs.pathExists(apiPackageDir)) nativeDeps[`@${projectName}/api`] = workspaceVersion;
|
|
6673
6679
|
if (Object.keys(nativeDeps).length > 0) await addPackageDependency({
|
|
6674
6680
|
customDependencies: nativeDeps,
|
|
6675
6681
|
projectDir: nativePackageDir
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-better-t-stack",
|
|
3
|
-
"version": "3.0.12-canary.
|
|
3
|
+
"version": "3.0.12-canary.b6015ca7",
|
|
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",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
+
import { google } from "@ai-sdk/google";
|
|
3
|
+
import { streamText, type UIMessage, convertToModelMessages } from "ai";
|
|
4
|
+
|
|
5
|
+
export const Route = createFileRoute("/api/ai/$")({
|
|
6
|
+
server: {
|
|
7
|
+
handlers: {
|
|
8
|
+
POST: async ({ request }) => {
|
|
9
|
+
try {
|
|
10
|
+
const { messages }: { messages: UIMessage[] } = await request.json();
|
|
11
|
+
|
|
12
|
+
const result = streamText({
|
|
13
|
+
model: google("gemini-2.5-flash"),
|
|
14
|
+
messages: convertToModelMessages(messages),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return result.toUIMessageStreamResponse();
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.error("AI API error:", error);
|
|
20
|
+
return new Response(
|
|
21
|
+
JSON.stringify({ error: "Failed to process AI request" }),
|
|
22
|
+
{
|
|
23
|
+
status: 500,
|
|
24
|
+
headers: { "Content-Type": "application/json" },
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
});
|
|
@@ -15,7 +15,7 @@ function RouteComponent() {
|
|
|
15
15
|
const [input, setInput] = useState("");
|
|
16
16
|
const { messages, sendMessage } = useChat({
|
|
17
17
|
transport: new DefaultChatTransport({
|
|
18
|
-
api: `${import.meta.env.VITE_SERVER_URL}/ai
|
|
18
|
+
api: {{#if (eq backend "self")}}"/api/ai"{{else}}`${import.meta.env.VITE_SERVER_URL}/ai`{{/if}},
|
|
19
19
|
}),
|
|
20
20
|
});
|
|
21
21
|
|