create-better-t-stack 2.50.0-canary.dd7000f2 → 2.50.1

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.
Files changed (92) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/index.d.ts +2 -2
  3. package/dist/index.js +1 -1
  4. package/dist/{src-dv6H37db.js → src-B8TD9m4n.js} +228 -518
  5. package/package.json +1 -2
  6. package/templates/api/orpc/server/{src → base/src/lib}/context.ts.hbs +6 -6
  7. package/templates/api/orpc/server/next/src/app/rpc/[...all]/route.ts.hbs +52 -0
  8. package/templates/api/orpc/web/nuxt/app/plugins/orpc.ts.hbs +1 -1
  9. package/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs +1 -1
  10. package/templates/api/orpc/web/solid/src/utils/orpc.ts.hbs +1 -1
  11. package/templates/api/orpc/web/svelte/src/lib/orpc.ts.hbs +1 -1
  12. package/templates/api/trpc/server/{src → base/src/lib}/context.ts.hbs +6 -6
  13. package/templates/api/trpc/server/next/src/app/trpc/[trpc]/route.ts +14 -0
  14. package/templates/api/trpc/web/react/base/src/utils/trpc.ts.hbs +2 -2
  15. package/templates/auth/better-auth/server/base/src/{index.ts.hbs → lib/auth.ts.hbs} +7 -7
  16. package/templates/auth/better-auth/server/next/src/app/api/auth/[...all]/route.ts +4 -0
  17. package/templates/backend/server/elysia/src/index.ts.hbs +6 -6
  18. package/templates/backend/server/express/src/index.ts.hbs +6 -6
  19. package/templates/backend/server/fastify/src/index.ts.hbs +6 -6
  20. package/templates/backend/server/hono/src/index.ts.hbs +7 -7
  21. package/templates/backend/server/next/next-env.d.ts +5 -0
  22. package/templates/backend/server/next/next.config.ts +7 -0
  23. package/templates/backend/server/next/package.json.hbs +27 -0
  24. package/templates/backend/server/next/src/app/route.ts +5 -0
  25. package/templates/backend/server/next/src/middleware.ts +19 -0
  26. package/templates/backend/server/next/tsconfig.json.hbs +33 -0
  27. package/templates/backend/server/{base → server-base}/package.json.hbs +1 -0
  28. package/templates/{api/trpc/server → backend/server/server-base}/src/routers/index.ts.hbs +2 -2
  29. package/templates/backend/server/{base → server-base}/tsconfig.json.hbs +10 -5
  30. package/templates/base/_gitignore +1 -47
  31. package/templates/base/package.json.hbs +3 -1
  32. package/templates/db/drizzle/mysql/drizzle.config.ts.hbs +2 -7
  33. package/templates/db/drizzle/mysql/src/{index.ts.hbs → db/index.ts.hbs} +1 -1
  34. package/templates/db/drizzle/postgres/drizzle.config.ts.hbs +2 -7
  35. package/templates/db/drizzle/postgres/src/{index.ts.hbs → db/index.ts.hbs} +1 -1
  36. package/templates/db/drizzle/sqlite/drizzle.config.ts.hbs +2 -7
  37. package/templates/db/drizzle/sqlite/src/{index.ts.hbs → db/index.ts.hbs} +1 -1
  38. package/templates/db/prisma/mongodb/prisma.config.ts.hbs +1 -5
  39. package/templates/db/prisma/mongodb/src/db/index.ts.hbs +5 -0
  40. package/templates/db/prisma/mysql/prisma.config.ts.hbs +1 -5
  41. package/templates/db/prisma/mysql/src/{index.ts.hbs → db/index.ts.hbs} +1 -1
  42. package/templates/db/prisma/postgres/prisma.config.ts.hbs +3 -7
  43. package/templates/db/prisma/postgres/src/{index.ts.hbs → db/index.ts.hbs} +1 -1
  44. package/templates/db/prisma/sqlite/prisma.config.ts.hbs +1 -5
  45. package/templates/db/prisma/sqlite/src/{index.ts.hbs → db/index.ts.hbs} +3 -3
  46. package/templates/examples/ai/server/next/src/app/ai/route.ts.hbs +15 -0
  47. package/templates/examples/todo/server/drizzle/base/src/routers/todo.ts.hbs +6 -6
  48. package/templates/examples/todo/server/mongoose/base/src/routers/todo.ts.hbs +4 -4
  49. package/templates/examples/todo/server/prisma/base/src/routers/todo.ts.hbs +4 -4
  50. package/templates/frontend/react/tanstack-router/src/routes/__root.tsx.hbs +1 -1
  51. package/templates/frontend/react/tanstack-start/src/routes/__root.tsx.hbs +1 -1
  52. package/templates/api/orpc/server/_gitignore +0 -34
  53. package/templates/api/orpc/server/package.json.hbs +0 -24
  54. package/templates/api/orpc/server/src/routers/index.ts.hbs +0 -55
  55. package/templates/api/orpc/server/tsconfig.json.hbs +0 -10
  56. package/templates/api/orpc/server/tsdown.config.ts.hbs +0 -7
  57. package/templates/api/trpc/server/_gitignore +0 -34
  58. package/templates/api/trpc/server/package.json.hbs +0 -23
  59. package/templates/api/trpc/server/tsconfig.json.hbs +0 -13
  60. package/templates/api/trpc/server/tsdown.config.ts.hbs +0 -7
  61. package/templates/auth/better-auth/server/base/_gitignore +0 -34
  62. package/templates/auth/better-auth/server/base/package.json.hbs +0 -24
  63. package/templates/auth/better-auth/server/base/tsconfig.json.hbs +0 -13
  64. package/templates/auth/better-auth/server/base/tsdown.config.ts.hbs +0 -7
  65. package/templates/backend/server/base/tsdown.config.ts.hbs +0 -14
  66. package/templates/base/tsconfig.base.json +0 -23
  67. package/templates/db/base/_gitignore +0 -34
  68. package/templates/db/base/package.json.hbs +0 -23
  69. package/templates/db/base/tsconfig.json.hbs +0 -13
  70. package/templates/db/base/tsdown.config.ts.hbs +0 -7
  71. package/templates/db/prisma/mongodb/src/index.ts.hbs +0 -5
  72. /package/templates/api/orpc/server/{src/index.ts.hbs → base/src/lib/orpc.ts.hbs} +0 -0
  73. /package/templates/api/trpc/server/{src/index.ts.hbs → base/src/lib/trpc.ts.hbs} +0 -0
  74. /package/templates/auth/better-auth/server/db/drizzle/mysql/src/{schema/auth.ts.hbs → db/schema/auth.ts} +0 -0
  75. /package/templates/auth/better-auth/server/db/drizzle/postgres/src/{schema/auth.ts.hbs → db/schema/auth.ts} +0 -0
  76. /package/templates/auth/better-auth/server/db/drizzle/sqlite/src/{schema/auth.ts.hbs → db/schema/auth.ts} +0 -0
  77. /package/templates/auth/better-auth/server/db/mongoose/mongodb/src/{models/auth.model.ts.hbs → db/models/auth.model.ts} +0 -0
  78. /package/templates/auth/better-auth/server/db/prisma/mongodb/prisma/schema/{auth.prisma.hbs → auth.prisma} +0 -0
  79. /package/templates/auth/better-auth/server/db/prisma/mysql/prisma/schema/{auth.prisma.hbs → auth.prisma} +0 -0
  80. /package/templates/auth/better-auth/server/db/prisma/postgres/prisma/schema/{auth.prisma.hbs → auth.prisma} +0 -0
  81. /package/templates/auth/better-auth/server/db/prisma/sqlite/prisma/schema/{auth.prisma.hbs → auth.prisma} +0 -0
  82. /package/templates/auth/better-auth/web/nuxt/app/middleware/{auth.ts.hbs → auth.ts} +0 -0
  83. /package/templates/backend/server/{base → server-base}/_gitignore +0 -0
  84. /package/templates/db/mongoose/mongodb/src/{index.ts.hbs → db/index.ts.hbs} +0 -0
  85. /package/templates/examples/todo/server/drizzle/mysql/src/{schema → db/schema}/todo.ts +0 -0
  86. /package/templates/examples/todo/server/drizzle/postgres/src/{schema → db/schema}/todo.ts +0 -0
  87. /package/templates/examples/todo/server/drizzle/sqlite/src/{schema → db/schema}/todo.ts +0 -0
  88. /package/templates/examples/todo/server/mongoose/mongodb/src/{models/todo.model.ts.hbs → db/models/todo.model.ts} +0 -0
  89. /package/templates/examples/todo/server/prisma/mongodb/prisma/schema/{todo.prisma.hbs → todo.prisma} +0 -0
  90. /package/templates/examples/todo/server/prisma/mysql/prisma/schema/{todo.prisma.hbs → todo.prisma} +0 -0
  91. /package/templates/examples/todo/server/prisma/postgres/prisma/schema/{todo.prisma.hbs → todo.prisma} +0 -0
  92. /package/templates/examples/todo/server/prisma/sqlite/prisma/schema/{todo.prisma.hbs → todo.prisma} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-better-t-stack",
3
- "version": "2.50.0-canary.dd7000f2",
3
+ "version": "2.50.1",
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",
@@ -77,7 +77,6 @@
77
77
  "tinyglobby": "^0.2.15",
78
78
  "trpc-cli": "^0.11.0",
79
79
  "ts-morph": "^27.0.0",
80
- "yaml": "^2.7.0",
81
80
  "zod": "^4.1.11"
82
81
  },
83
82
  "devDependencies": {
@@ -1,7 +1,7 @@
1
- {{#if (and (eq backend 'self') (includes frontend "next"))}}
1
+ {{#if (eq backend 'next')}}
2
2
  import type { NextRequest } from "next/server";
3
3
  {{#if (eq auth "better-auth")}}
4
- import { auth } from "@{{projectName}}/auth";
4
+ import { auth } from "./auth";
5
5
  {{/if}}
6
6
 
7
7
  export async function createContext(req: NextRequest) {
@@ -20,7 +20,7 @@ export async function createContext(req: NextRequest) {
20
20
  {{else if (eq backend 'hono')}}
21
21
  import type { Context as HonoContext } from "hono";
22
22
  {{#if (eq auth "better-auth")}}
23
- import { auth } from "@{{projectName}}/auth";
23
+ import { auth } from "./auth";
24
24
  {{/if}}
25
25
 
26
26
  export type CreateContextOptions = {
@@ -46,7 +46,7 @@ export async function createContext({ context }: CreateContextOptions) {
46
46
  {{else if (eq backend 'elysia')}}
47
47
  import type { Context as ElysiaContext } from "elysia";
48
48
  {{#if (eq auth "better-auth")}}
49
- import { auth } from "@{{projectName}}/auth";
49
+ import { auth } from "./auth";
50
50
  {{/if}}
51
51
 
52
52
  export type CreateContextOptions = {
@@ -72,7 +72,7 @@ export async function createContext({ context }: CreateContextOptions) {
72
72
  {{else if (eq backend 'express')}}
73
73
  {{#if (eq auth "better-auth")}}
74
74
  import { fromNodeHeaders } from "better-auth/node";
75
- import { auth } from "@{{projectName}}/auth";
75
+ import { auth } from "./auth";
76
76
  {{/if}}
77
77
 
78
78
  export async function createContext(opts: any) {
@@ -95,7 +95,7 @@ export async function createContext(opts: any) {
95
95
  import type { IncomingHttpHeaders } from "node:http";
96
96
  {{#if (eq auth "better-auth")}}
97
97
  import { fromNodeHeaders } from "better-auth/node";
98
- import { auth } from "@{{projectName}}/auth";
98
+ import { auth } from "./auth";
99
99
  {{/if}}
100
100
 
101
101
  export async function createContext(req: IncomingHttpHeaders) {
@@ -0,0 +1,52 @@
1
+ {{#if (eq auth "better-auth")}}
2
+ import { createContext } from '@/lib/context'
3
+ {{/if}}
4
+ import { appRouter } from '@/routers'
5
+ import { OpenAPIHandler } from '@orpc/openapi/fetch'
6
+ import { OpenAPIReferencePlugin } from '@orpc/openapi/plugins'
7
+ import { ZodToJsonSchemaConverter } from '@orpc/zod/zod4'
8
+ import { RPCHandler } from '@orpc/server/fetch'
9
+ import { onError } from '@orpc/server'
10
+ import { NextRequest } from 'next/server'
11
+
12
+ const rpcHandler = new RPCHandler(appRouter, {
13
+ interceptors: [
14
+ onError((error) => {
15
+ console.error(error)
16
+ }),
17
+ ],
18
+ })
19
+ const apiHandler = new OpenAPIHandler(appRouter, {
20
+ plugins: [
21
+ new OpenAPIReferencePlugin({
22
+ schemaConverters: [new ZodToJsonSchemaConverter()],
23
+ }),
24
+ ],
25
+ interceptors: [
26
+ onError((error) => {
27
+ console.error(error)
28
+ }),
29
+ ],
30
+ })
31
+
32
+ async function handleRequest(req: NextRequest) {
33
+ const rpcResult = await rpcHandler.handle(req, {
34
+ prefix: '/rpc',
35
+ context: {{#if (eq auth "better-auth")}}await createContext(req){{else}}{}{{/if}},
36
+ })
37
+ if (rpcResult.response) return rpcResult.response
38
+
39
+ const apiResult = await apiHandler.handle(req, {
40
+ prefix: '/rpc/api',
41
+ context: {{#if (eq auth "better-auth")}}await createContext(req){{else}}{}{{/if}},
42
+ })
43
+ if (apiResult.response) return apiResult.response
44
+
45
+ return new Response('Not found', { status: 404 })
46
+ }
47
+
48
+ export const GET = handleRequest
49
+ export const POST = handleRequest
50
+ export const PUT = handleRequest
51
+ export const PATCH = handleRequest
52
+ export const DELETE = handleRequest
@@ -1,5 +1,5 @@
1
1
  import { defineNuxtPlugin, useRuntimeConfig } from '#app'
2
- import type { AppRouterClient } from "@{{projectName}}/api/src/routers/index";
2
+ import type { AppRouterClient } from "../../../server/src/routers/index";
3
3
  import { createORPCClient } from '@orpc/client'
4
4
  import { RPCLink } from '@orpc/client/fetch'
5
5
  import { createTanstackQueryUtils } from "@orpc/tanstack-query";
@@ -3,7 +3,7 @@ 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/src/routers/index";
6
+ import type { AppRouterClient } from "../../../server/src/routers/index";
7
7
 
8
8
  export const queryClient = new QueryClient({
9
9
  queryCache: new QueryCache({
@@ -2,7 +2,7 @@ import { createORPCClient } from "@orpc/client";
2
2
  import { RPCLink } from "@orpc/client/fetch";
3
3
  import { createTanstackQueryUtils } from "@orpc/tanstack-query";
4
4
  import { QueryCache, QueryClient } from "@tanstack/solid-query";
5
- import type { AppRouterClient } from "@{{projectName}}/api/src/routers/index";
5
+ import type { AppRouterClient } from "../../../server/src/routers/index";
6
6
 
7
7
  export const queryClient = new QueryClient({
8
8
  queryCache: new QueryCache({
@@ -3,7 +3,7 @@ import { createORPCClient } from "@orpc/client";
3
3
  import { RPCLink } from "@orpc/client/fetch";
4
4
  import { createTanstackQueryUtils } from "@orpc/tanstack-query";
5
5
  import { QueryCache, QueryClient } from "@tanstack/svelte-query";
6
- import type { AppRouterClient } from "@{{projectName}}/api/src/routers/index";
6
+ import type { AppRouterClient } from "../../../server/src/routers/index";
7
7
 
8
8
  export const queryClient = new QueryClient({
9
9
  queryCache: new QueryCache({
@@ -1,7 +1,7 @@
1
- {{#if (and (eq backend 'self') (includes frontend "next"))}}
1
+ {{#if (eq backend 'next')}}
2
2
  import type { NextRequest } from "next/server";
3
3
  {{#if (eq auth "better-auth")}}
4
- import { auth } from "@{{projectName}}/auth";
4
+ import { auth } from "./auth";
5
5
  {{/if}}
6
6
 
7
7
  export async function createContext(req: NextRequest) {
@@ -23,7 +23,7 @@ export async function createContext(req: NextRequest) {
23
23
  {{else if (eq backend 'hono')}}
24
24
  import type { Context as HonoContext } from "hono";
25
25
  {{#if (eq auth "better-auth")}}
26
- import { auth } from "@{{projectName}}/auth";
26
+ import { auth } from "./auth";
27
27
  {{/if}}
28
28
 
29
29
  export type CreateContextOptions = {
@@ -49,7 +49,7 @@ export async function createContext({ context }: CreateContextOptions) {
49
49
  {{else if (eq backend 'elysia')}}
50
50
  import type { Context as ElysiaContext } from "elysia";
51
51
  {{#if (eq auth "better-auth")}}
52
- import { auth } from "@{{projectName}}/auth";
52
+ import { auth } from "./auth";
53
53
  {{/if}}
54
54
 
55
55
  export type CreateContextOptions = {
@@ -76,7 +76,7 @@ export async function createContext({ context }: CreateContextOptions) {
76
76
  import type { CreateExpressContextOptions } from "@trpc/server/adapters/express";
77
77
  {{#if (eq auth "better-auth")}}
78
78
  import { fromNodeHeaders } from "better-auth/node";
79
- import { auth } from "@{{projectName}}/auth";
79
+ import { auth } from "./auth";
80
80
  {{/if}}
81
81
 
82
82
  export async function createContext(opts: CreateExpressContextOptions) {
@@ -99,7 +99,7 @@ export async function createContext(opts: CreateExpressContextOptions) {
99
99
  import type { CreateFastifyContextOptions } from "@trpc/server/adapters/fastify";
100
100
  {{#if (eq auth "better-auth")}}
101
101
  import { fromNodeHeaders } from "better-auth/node";
102
- import { auth } from "@{{projectName}}/auth";
102
+ import { auth } from "./auth";
103
103
  {{/if}}
104
104
 
105
105
  export async function createContext({ req, res }: CreateFastifyContextOptions) {
@@ -0,0 +1,14 @@
1
+ import { fetchRequestHandler } from '@trpc/server/adapters/fetch';
2
+ import { appRouter } from '@/routers';
3
+ import { createContext } from '@/lib/context';
4
+ import { NextRequest } from 'next/server';
5
+
6
+ function handler(req: NextRequest) {
7
+ return fetchRequestHandler({
8
+ endpoint: '/trpc',
9
+ req,
10
+ router: appRouter,
11
+ createContext: () => createContext(req)
12
+ });
13
+ }
14
+ export { handler as GET, handler as POST };
@@ -47,13 +47,13 @@ export const trpc = createTRPCOptionsProxy<AppRouter>({
47
47
 
48
48
  {{else if (includes frontend 'tanstack-start')}}
49
49
  import { createTRPCContext } from "@trpc/tanstack-react-query";
50
- import type { AppRouter } from "@{{projectName}}/api/src/routers/index";
50
+ import type { AppRouter } from "../../../server/src/routers";
51
51
 
52
52
  export const { TRPCProvider, useTRPC, useTRPCClient } =
53
53
  createTRPCContext<AppRouter>();
54
54
 
55
55
  {{else}}
56
- import type { AppRouter } from "@{{projectName}}/api/src/routers/index";
56
+ import type { AppRouter } from "../../../server/src/routers";
57
57
  import { QueryCache, QueryClient } from "@tanstack/react-query";
58
58
  import { createTRPCClient, httpBatchLink } from "@trpc/client";
59
59
  import { createTRPCOptionsProxy } from "@trpc/tanstack-react-query";
@@ -8,7 +8,7 @@ import { expo } from "@better-auth/expo";
8
8
  import { polar, checkout, portal } from "@polar-sh/better-auth";
9
9
  import { polarClient } from "./payments";
10
10
  {{/if}}
11
- import prisma from "@{{projectName}}/db";
11
+ import prisma from "../db";
12
12
 
13
13
  export const auth = betterAuth<BetterAuthOptions>({
14
14
  database: prismaAdapter(prisma, {
@@ -66,7 +66,7 @@ export const auth = betterAuth<BetterAuthOptions>({
66
66
  {{/if}}
67
67
 
68
68
  {{#if (eq orm "drizzle")}}
69
- {{#if (or (eq runtime "bun") (eq runtime "node") (eq runtime "none"))}}
69
+ {{#if (or (eq runtime "bun") (eq runtime "node"))}}
70
70
  import { betterAuth, type BetterAuthOptions } from "better-auth";
71
71
  import { drizzleAdapter } from "better-auth/adapters/drizzle";
72
72
  {{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
@@ -76,8 +76,8 @@ import { expo } from "@better-auth/expo";
76
76
  import { polar, checkout, portal } from "@polar-sh/better-auth";
77
77
  import { polarClient } from "./payments";
78
78
  {{/if}}
79
- import { db } from "@{{projectName}}/db";
80
- import * as schema from "@{{projectName}}/db/schema/auth";
79
+ import { db } from "../db";
80
+ import * as schema from "../db/schema/auth";
81
81
 
82
82
  export const auth = betterAuth<BetterAuthOptions>({
83
83
  database: drizzleAdapter(db, {
@@ -144,8 +144,8 @@ import { expo } from "@better-auth/expo";
144
144
  import { polar, checkout, portal } from "@polar-sh/better-auth";
145
145
  import { polarClient } from "./payments";
146
146
  {{/if}}
147
- import { db } from "@{{projectName}}/db";
148
- import * as schema from "@{{projectName}}/db/schema/auth";
147
+ import { db } from "../db";
148
+ import * as schema from "../db/schema/auth";
149
149
  import { env } from "cloudflare:workers";
150
150
 
151
151
  export const auth = betterAuth<BetterAuthOptions>({
@@ -226,7 +226,7 @@ import { expo } from "@better-auth/expo";
226
226
  import { polar, checkout, portal } from "@polar-sh/better-auth";
227
227
  import { polarClient } from "./payments";
228
228
  {{/if}}
229
- import { client } from "@{{projectName}}/db";
229
+ import { client } from "../db";
230
230
 
231
231
  export const auth = betterAuth<BetterAuthOptions>({
232
232
  database: mongodbAdapter(client),
@@ -0,0 +1,4 @@
1
+ import { auth } from "@/lib/auth";
2
+ import { toNextJsHandler } from "better-auth/next-js";
3
+
4
+ export const { GET, POST } = toNextJsHandler(auth.handler);
@@ -9,8 +9,8 @@ import { google } from "@ai-sdk/google";
9
9
  import { convertToModelMessages, streamText } from "ai";
10
10
  {{/if}}
11
11
  {{#if (eq api "trpc")}}
12
- import { createContext } from "@{{projectName}}/api/context";
13
- import { appRouter } from "@{{projectName}}/api/routers/index";
12
+ import { createContext } from "./lib/context";
13
+ import { appRouter } from "./routers/index";
14
14
  import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
15
15
  {{/if}}
16
16
  {{#if (eq api "orpc")}}
@@ -19,11 +19,11 @@ import { OpenAPIReferencePlugin } from "@orpc/openapi/plugins";
19
19
  import { ZodToJsonSchemaConverter } from "@orpc/zod/zod4";
20
20
  import { RPCHandler } from "@orpc/server/fetch";
21
21
  import { onError } from "@orpc/server";
22
- import { appRouter } from "@{{projectName}}/api/routers/index";
23
- import { createContext } from "@{{projectName}}/api/context";
22
+ import { appRouter } from "./routers";
23
+ import { createContext } from "./lib/context";
24
24
  {{/if}}
25
25
  {{#if (eq auth "better-auth")}}
26
- import { auth } from "@{{projectName}}/auth";
26
+ import { auth } from "./lib/auth";
27
27
  {{/if}}
28
28
 
29
29
  {{#if (eq api "orpc")}}
@@ -104,7 +104,7 @@ const app = new Elysia()
104
104
  const body = await context.request.json();
105
105
  const uiMessages = body.messages || [];
106
106
  const result = streamText({
107
- model: google("gemini-2.5-flash"),
107
+ model: google("gemini-2.0-flash"),
108
108
  messages: convertToModelMessages(uiMessages)
109
109
  });
110
110
 
@@ -1,8 +1,8 @@
1
1
  import "dotenv/config";
2
2
  {{#if (eq api "trpc")}}
3
3
  import { createExpressMiddleware } from "@trpc/server/adapters/express";
4
- import { createContext } from "@{{projectName}}/api/context";
5
- import { appRouter } from "@{{projectName}}/api/routers/index";
4
+ import { createContext } from "./lib/context";
5
+ import { appRouter } from "./routers/index";
6
6
  {{/if}}
7
7
  {{#if (eq api "orpc")}}
8
8
  import { OpenAPIHandler } from "@orpc/openapi/node";
@@ -10,9 +10,9 @@ import { OpenAPIReferencePlugin } from "@orpc/openapi/plugins";
10
10
  import { ZodToJsonSchemaConverter } from "@orpc/zod/zod4";
11
11
  import { RPCHandler } from "@orpc/server/node";
12
12
  import { onError } from "@orpc/server";
13
- import { appRouter } from "@{{projectName}}/api/routers/index";
13
+ import { appRouter } from "./routers";
14
14
  {{#if (eq auth "better-auth")}}
15
- import { createContext } from "@{{projectName}}/api/context";
15
+ import { createContext } from "./lib/context";
16
16
  {{/if}}
17
17
  {{/if}}
18
18
  import cors from "cors";
@@ -22,7 +22,7 @@ import { streamText, type UIMessage, convertToModelMessages } from "ai";
22
22
  import { google } from "@ai-sdk/google";
23
23
  {{/if}}
24
24
  {{#if (eq auth "better-auth")}}
25
- import { auth } from "@{{projectName}}/auth";
25
+ import { auth } from "./lib/auth";
26
26
  import { toNodeHandler } from "better-auth/node";
27
27
  {{/if}}
28
28
 
@@ -105,7 +105,7 @@ app.use(express.json());
105
105
  app.post("/ai", async (req, res) => {
106
106
  const { messages = [] } = (req.body || {}) as { messages: UIMessage[] };
107
107
  const result = streamText({
108
- model: google("gemini-2.5-flash"),
108
+ model: google("gemini-1.5-flash"),
109
109
  messages: convertToModelMessages(messages),
110
110
  });
111
111
  result.pipeUIMessageStreamToResponse(res);
@@ -4,8 +4,8 @@ import fastifyCors from "@fastify/cors";
4
4
 
5
5
  {{#if (eq api "trpc")}}
6
6
  import { fastifyTRPCPlugin, type FastifyTRPCPluginOptions } from "@trpc/server/adapters/fastify";
7
- import { createContext } from "@{{projectName}}/api/context";
8
- import { appRouter, type AppRouter } from "@{{projectName}}/api/routers/index";
7
+ import { createContext } from "./lib/context";
8
+ import { appRouter, type AppRouter } from "./routers/index";
9
9
  {{/if}}
10
10
 
11
11
  {{#if (eq api "orpc")}}
@@ -15,10 +15,10 @@ import { ZodToJsonSchemaConverter } from "@orpc/zod/zod4";
15
15
  import { RPCHandler } from "@orpc/server/node";
16
16
  import { CORSPlugin } from "@orpc/server/plugins";
17
17
  import { onError } from "@orpc/server";
18
- import { appRouter } from "@{{projectName}}/api/routers/index";
18
+ import { appRouter } from "./routers/index";
19
19
  import { createServer } from "node:http";
20
20
  {{#if (eq auth "better-auth")}}
21
- import { createContext } from "@{{projectName}}/api/context";
21
+ import { createContext } from "./lib/context";
22
22
  {{/if}}
23
23
  {{/if}}
24
24
 
@@ -28,7 +28,7 @@ import { google } from "@ai-sdk/google";
28
28
  {{/if}}
29
29
 
30
30
  {{#if (eq auth "better-auth")}}
31
- import { auth } from "@{{projectName}}/auth";
31
+ import { auth } from "./lib/auth";
32
32
  {{/if}}
33
33
 
34
34
  const baseCorsConfig = {
@@ -161,7 +161,7 @@ interface AiRequestBody {
161
161
  fastify.post('/ai', async function (request) {
162
162
  const { messages } = request.body as AiRequestBody;
163
163
  const result = streamText({
164
- model: google('gemini-2.5-flash'),
164
+ model: google('gemini-1.5-flash'),
165
165
  messages: convertToModelMessages(messages),
166
166
  });
167
167
 
@@ -10,16 +10,16 @@ import { OpenAPIReferencePlugin } from "@orpc/openapi/plugins";
10
10
  import { ZodToJsonSchemaConverter } from "@orpc/zod/zod4";
11
11
  import { RPCHandler } from "@orpc/server/fetch";
12
12
  import { onError } from "@orpc/server";
13
- import { createContext } from "@{{projectName}}/api/context";
14
- import { appRouter } from "@{{projectName}}/api/routers/index";
13
+ import { createContext } from "./lib/context";
14
+ import { appRouter } from "./routers/index";
15
15
  {{/if}}
16
16
  {{#if (eq api "trpc")}}
17
17
  import { trpcServer } from "@hono/trpc-server";
18
- import { createContext } from "@{{projectName}}/api/context";
19
- import { appRouter } from "@{{projectName}}/api/routers/index";
18
+ import { createContext } from "./lib/context";
19
+ import { appRouter } from "./routers/index";
20
20
  {{/if}}
21
21
  {{#if (eq auth "better-auth")}}
22
- import { auth } from "@{{projectName}}/auth";
22
+ import { auth } from "./lib/auth";
23
23
  {{/if}}
24
24
  import { Hono } from "hono";
25
25
  import { cors } from "hono/cors";
@@ -121,7 +121,7 @@ app.post("/ai", async (c) => {
121
121
  const body = await c.req.json();
122
122
  const uiMessages = body.messages || [];
123
123
  const result = streamText({
124
- model: google("gemini-2.5-flash"),
124
+ model: google("gemini-1.5-flash"),
125
125
  messages: convertToModelMessages(uiMessages),
126
126
  });
127
127
 
@@ -137,7 +137,7 @@ app.post("/ai", async (c) => {
137
137
  apiKey: env.GOOGLE_GENERATIVE_AI_API_KEY,
138
138
  });
139
139
  const result = streamText({
140
- model: google("gemini-2.5-flash"),
140
+ model: google("gemini-1.5-flash"),
141
141
  messages: convertToModelMessages(uiMessages),
142
142
  });
143
143
 
@@ -0,0 +1,5 @@
1
+ /// <reference types="next" />
2
+ /// <reference types="next/image-types/global" />
3
+
4
+ // NOTE: This file should not be edited
5
+ // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
@@ -0,0 +1,7 @@
1
+ import type { NextConfig } from "next";
2
+
3
+ const nextConfig: NextConfig = {
4
+ typedRoutes: true,
5
+ };
6
+
7
+ export default nextConfig;
@@ -0,0 +1,27 @@
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.5.0",
12
+ "react": "19.1.0",
13
+ "react-dom": "19.1.0",
14
+ "dotenv": "^17.2.1"
15
+ },
16
+ {{#if (eq dbSetup 'supabase')}}
17
+ "trustedDependencies": [
18
+ "supabase"
19
+ ],
20
+ {{/if}}
21
+ "devDependencies": {
22
+ "@types/node": "^20",
23
+ "@types/react": "~19.1.10",
24
+ "zod": "^4.0.13",
25
+ "typescript": "^5"
26
+ }
27
+ }
@@ -0,0 +1,5 @@
1
+ import { NextResponse } from "next/server";
2
+
3
+ export async function GET() {
4
+ return NextResponse.json({ message: "OK" });
5
+ }
@@ -0,0 +1,19 @@
1
+ import { NextResponse } from "next/server";
2
+
3
+ export function middleware() {
4
+ const res = NextResponse.next()
5
+
6
+ res.headers.append('Access-Control-Allow-Credentials', "true")
7
+ res.headers.append('Access-Control-Allow-Origin', process.env.CORS_ORIGIN || "")
8
+ res.headers.append('Access-Control-Allow-Methods', 'GET,POST,OPTIONS')
9
+ res.headers.append(
10
+ 'Access-Control-Allow-Headers',
11
+ 'Content-Type, Authorization'
12
+ )
13
+
14
+ return res
15
+ }
16
+
17
+ export const config = {
18
+ matcher: '/:path*',
19
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2017",
4
+ "lib": ["dom", "dom.iterable", "esnext"],
5
+ "allowJs": true,
6
+ "skipLibCheck": true,
7
+ "strict": true,
8
+ "noEmit": true,
9
+ "esModuleInterop": true,
10
+ "module": "esnext",
11
+ "moduleResolution": "bundler",
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "jsx": "preserve",
15
+ {{#unless (or (eq backend "convex") (eq backend "none"))}}
16
+ "composite": true,
17
+ {{/unless}}
18
+ "incremental": true,
19
+ "plugins": [
20
+ {
21
+ "name": "next"
22
+ }
23
+ ],
24
+ "paths": {
25
+ "@/*": ["./src/*"]
26
+ {{#if (eq orm 'prisma')}},
27
+ "prisma": ["node_modules/prisma"]
28
+ {{/if}}
29
+ },
30
+ },
31
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
32
+ "exclude": ["node_modules"]
33
+ }
@@ -17,6 +17,7 @@
17
17
  ],
18
18
  {{/if}}
19
19
  "devDependencies": {
20
+ "tsdown": "^0.15.1",
20
21
  "typescript": "^5.8.2"
21
22
  }
22
23
  }
@@ -1,5 +1,5 @@
1
1
  {{#if (eq api "orpc")}}
2
- import { {{#if (eq auth "better-auth")}}protectedProcedure, {{/if}}publicProcedure } from "../index";
2
+ import { {{#if (eq auth "better-auth")}}protectedProcedure, {{/if}}publicProcedure } from "../lib/orpc";
3
3
  import type { RouterClient } from "@orpc/server";
4
4
  {{#if (includes examples "todo")}}
5
5
  import { todoRouter } from "./todo";
@@ -27,7 +27,7 @@ export type AppRouterClient = RouterClient<typeof appRouter>;
27
27
  import {
28
28
  {{#if (eq auth "better-auth")}}protectedProcedure, {{/if}}publicProcedure,
29
29
  router,
30
- } from "../index";
30
+ } from "../lib/trpc";
31
31
  {{#if (includes examples "todo")}}
32
32
  import { todoRouter } from "./todo";
33
33
  {{/if}}
@@ -1,13 +1,17 @@
1
1
  {
2
- "extends": "../../tsconfig.base.json",
3
2
  "compilerOptions": {
4
- "composite": true,
5
- "outDir": "dist",
6
- "baseUrl": ".",
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "verbatimModuleSyntax": true,
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "baseUrl": "./",
7
10
  "paths": {
8
11
  "@/*": ["./src/*"]{{#if (eq orm "prisma")}},
9
12
  "prisma": ["node_modules/prisma"]{{/if}}
10
13
  },
14
+ "outDir": "./dist",
11
15
  "types": [
12
16
  {{#if (eq runtime "node")}}
13
17
  "node"
@@ -20,7 +24,8 @@
20
24
  "bun"
21
25
  {{/if}}{{#if (eq serverDeploy "alchemy")}},
22
26
  "@cloudflare/workers-types"{{/if}}
23
- ],
27
+ ]{{#unless (or (eq backend "convex") (eq backend "none"))}},
28
+ "composite": true{{/unless}},
24
29
  "jsx": "react-jsx"{{#if (eq backend "hono")}},
25
30
  "jsxImportSource": "hono/jsx"{{/if}}
26
31
  }