create-better-t-stack 3.11.0 → 3.12.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/chunk-Dt3mZKp0.mjs +24 -0
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +40 -60
- package/dist/index.mjs +2 -2
- package/dist/{src-XVvJUQ_h.mjs → src-DBVnwTkj.mjs} +668 -631
- package/package.json +2 -2
- package/templates/addons/turborepo/turbo.json.hbs +13 -0
- package/templates/api/orpc/native/utils/orpc.ts.hbs +21 -20
- package/templates/api/orpc/web/nuxt/app/plugins/orpc.ts.hbs +3 -5
- package/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs +73 -67
- package/templates/api/orpc/web/solid/src/utils/orpc.ts.hbs +15 -14
- package/templates/api/trpc/native/utils/trpc.ts.hbs +8 -7
- package/templates/api/trpc/web/react/base/src/utils/trpc.ts.hbs +59 -57
- package/templates/auth/better-auth/convex/backend/convex/auth.ts.hbs +3 -5
- package/templates/auth/better-auth/convex/backend/convex/privateData.ts.hbs +13 -12
- package/templates/auth/better-auth/convex/native/base/lib/auth-client.ts.hbs +10 -9
- package/templates/auth/better-auth/convex/web/react/next/src/lib/auth-client.ts.hbs +2 -2
- package/templates/auth/better-auth/convex/web/react/next/src/lib/auth-server.ts.hbs +11 -9
- package/templates/auth/better-auth/convex/web/react/tanstack-router/src/lib/auth-client.ts.hbs +5 -4
- package/templates/auth/better-auth/convex/web/react/tanstack-start/src/lib/auth-server.ts.hbs +8 -7
- package/templates/auth/better-auth/native/base/lib/auth-client.ts.hbs +9 -8
- package/templates/auth/better-auth/server/base/src/index.ts.hbs +239 -235
- package/templates/auth/better-auth/web/nuxt/app/plugins/auth-client.ts.hbs +2 -3
- package/templates/auth/better-auth/web/react/base/src/lib/auth-client.ts.hbs +9 -11
- package/templates/auth/better-auth/web/solid/src/lib/auth-client.ts.hbs +3 -2
- package/templates/backend/server/elysia/src/index.ts.hbs +71 -71
- package/templates/backend/server/express/src/index.ts.hbs +57 -57
- package/templates/backend/server/fastify/src/index.ts.hbs +107 -107
- package/templates/backend/server/hono/src/index.ts.hbs +75 -85
- package/templates/base/tsconfig.json.hbs +3 -0
- package/templates/db/drizzle/mysql/src/index.ts.hbs +23 -30
- package/templates/db/drizzle/postgres/src/index.ts.hbs +6 -13
- package/templates/db/drizzle/sqlite/src/index.ts.hbs +11 -18
- package/templates/db/mongoose/mongodb/src/index.ts.hbs +3 -2
- package/templates/db/prisma/mongodb/prisma/schema/schema.prisma.hbs +1 -1
- package/templates/db/prisma/mysql/prisma/schema/schema.prisma.hbs +1 -1
- package/templates/db/prisma/mysql/prisma.config.ts.hbs +16 -16
- package/templates/db/prisma/mysql/src/index.ts.hbs +16 -15
- package/templates/db/prisma/postgres/prisma/schema/schema.prisma.hbs +1 -1
- package/templates/db/prisma/postgres/src/index.ts.hbs +10 -9
- package/templates/db/prisma/sqlite/prisma/schema/schema.prisma.hbs +1 -1
- package/templates/db/prisma/sqlite/src/index.ts.hbs +4 -7
- package/templates/examples/ai/native/bare/app/(drawer)/ai.tsx.hbs +2 -1
- package/templates/examples/ai/native/unistyles/app/(drawer)/ai.tsx.hbs +2 -1
- package/templates/examples/ai/native/uniwind/app/(drawer)/ai.tsx.hbs +2 -1
- package/templates/examples/ai/web/nuxt/app/pages/ai.vue.hbs +1 -3
- package/templates/examples/ai/web/react/next/src/app/ai/page.tsx.hbs +4 -3
- package/templates/examples/ai/web/react/react-router/src/routes/ai.tsx.hbs +2 -1
- package/templates/examples/ai/web/react/tanstack-router/src/routes/ai.tsx.hbs +4 -1
- package/templates/examples/ai/web/react/tanstack-start/src/routes/ai.tsx.hbs +4 -1
- package/templates/frontend/native/bare/app/_layout.tsx.hbs +4 -2
- package/templates/frontend/native/unistyles/app/_layout.tsx.hbs +4 -2
- package/templates/frontend/native/uniwind/app/_layout.tsx.hbs +4 -3
- package/templates/frontend/nuxt/nuxt.config.ts.hbs +6 -3
- package/templates/frontend/react/next/next.config.ts.hbs +9 -8
- package/templates/frontend/react/next/src/components/providers.tsx.hbs +4 -1
- package/templates/frontend/react/next/tsconfig.json.hbs +2 -2
- package/templates/frontend/react/react-router/src/root.tsx.hbs +3 -4
- package/templates/frontend/react/tanstack-router/src/main.tsx.hbs +3 -2
- package/templates/frontend/react/tanstack-start/src/router.tsx.hbs +100 -108
- package/templates/frontend/react/tanstack-start/src/routes/__root.tsx.hbs +25 -7
- package/templates/packages/config/tsconfig.base.json.hbs +1 -1
- package/templates/{deploy/alchemy → packages/env}/env.d.ts.hbs +6 -4
- package/templates/packages/env/package.json.hbs +7 -0
- package/templates/packages/env/src/native.ts.hbs +21 -0
- package/templates/packages/env/src/server.ts.hbs +38 -0
- package/templates/packages/env/src/web.ts.hbs +89 -0
- package/templates/packages/env/tsconfig.json.hbs +3 -0
- package/templates/{deploy/alchemy → packages/infra}/alchemy.run.ts.hbs +86 -82
- package/templates/packages/infra/package.json.hbs +10 -0
- package/templates/payments/polar/server/base/src/lib/payments.ts.hbs +3 -2
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
import "dotenv/config";
|
|
3
|
-
{{/if}}
|
|
4
|
-
{{#if (eq runtime "workers")}}
|
|
5
|
-
import { env } from "cloudflare:workers";
|
|
6
|
-
{{/if}}
|
|
1
|
+
import { env } from "@{{projectName}}/env/server";
|
|
7
2
|
{{#if (eq api "orpc")}}
|
|
8
3
|
import { OpenAPIHandler } from "@orpc/openapi/fetch";
|
|
9
4
|
import { OpenAPIReferencePlugin } from "@orpc/openapi/plugins";
|
|
@@ -37,20 +32,15 @@ const app = new Hono();
|
|
|
37
32
|
|
|
38
33
|
app.use(logger());
|
|
39
34
|
app.use(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
{{#if (eq auth "better-auth")}}
|
|
50
|
-
allowHeaders: ["Content-Type", "Authorization"],
|
|
51
|
-
credentials: true,
|
|
52
|
-
{{/if}}
|
|
53
|
-
})
|
|
35
|
+
"/*",
|
|
36
|
+
cors({
|
|
37
|
+
origin: env.CORS_ORIGIN,
|
|
38
|
+
allowMethods: ["GET", "POST", "OPTIONS"],
|
|
39
|
+
{{#if (eq auth "better-auth")}}
|
|
40
|
+
allowHeaders: ["Content-Type", "Authorization"],
|
|
41
|
+
credentials: true,
|
|
42
|
+
{{/if}}
|
|
43
|
+
})
|
|
54
44
|
);
|
|
55
45
|
|
|
56
46
|
{{#if (eq auth "better-auth")}}
|
|
@@ -59,107 +49,107 @@ app.on(["POST", "GET"], "/api/auth/*", (c) => auth.handler(c.req.raw));
|
|
|
59
49
|
|
|
60
50
|
{{#if (eq api "orpc")}}
|
|
61
51
|
export const apiHandler = new OpenAPIHandler(appRouter, {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
52
|
+
plugins: [
|
|
53
|
+
new OpenAPIReferencePlugin({
|
|
54
|
+
schemaConverters: [new ZodToJsonSchemaConverter()],
|
|
55
|
+
}),
|
|
56
|
+
],
|
|
57
|
+
interceptors: [
|
|
58
|
+
onError((error) => {
|
|
59
|
+
console.error(error);
|
|
60
|
+
}),
|
|
61
|
+
],
|
|
72
62
|
});
|
|
73
63
|
|
|
74
64
|
export const rpcHandler = new RPCHandler(appRouter, {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
65
|
+
interceptors: [
|
|
66
|
+
onError((error) => {
|
|
67
|
+
console.error(error);
|
|
68
|
+
}),
|
|
69
|
+
],
|
|
80
70
|
});
|
|
81
71
|
|
|
82
72
|
app.use("/*", async (c, next) => {
|
|
83
|
-
|
|
73
|
+
const context = await createContext({ context: c });
|
|
84
74
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
75
|
+
const rpcResult = await rpcHandler.handle(c.req.raw, {
|
|
76
|
+
prefix: "/rpc",
|
|
77
|
+
context: context,
|
|
78
|
+
});
|
|
89
79
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
80
|
+
if (rpcResult.matched) {
|
|
81
|
+
return c.newResponse(rpcResult.response.body, rpcResult.response);
|
|
82
|
+
}
|
|
93
83
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
84
|
+
const apiResult = await apiHandler.handle(c.req.raw, {
|
|
85
|
+
prefix: "/api-reference",
|
|
86
|
+
context: context,
|
|
87
|
+
});
|
|
98
88
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
89
|
+
if (apiResult.matched) {
|
|
90
|
+
return c.newResponse(apiResult.response.body, apiResult.response);
|
|
91
|
+
}
|
|
102
92
|
|
|
103
|
-
|
|
93
|
+
await next();
|
|
104
94
|
});
|
|
105
95
|
{{/if}}
|
|
106
96
|
|
|
107
97
|
{{#if (eq api "trpc")}}
|
|
108
98
|
app.use(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
99
|
+
"/trpc/*",
|
|
100
|
+
trpcServer({
|
|
101
|
+
router: appRouter,
|
|
102
|
+
createContext: (_opts, context) => {
|
|
103
|
+
return createContext({ context });
|
|
104
|
+
},
|
|
105
|
+
})
|
|
116
106
|
);
|
|
117
107
|
{{/if}}
|
|
118
108
|
|
|
119
109
|
{{#if (and (includes examples "ai") (or (eq runtime "bun") (eq runtime "node")))}}
|
|
120
110
|
app.post("/ai", async (c) => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
111
|
+
const body = await c.req.json();
|
|
112
|
+
const uiMessages = body.messages || [];
|
|
113
|
+
const result = streamText({
|
|
114
|
+
model: google("gemini-2.5-flash"),
|
|
115
|
+
messages: convertToModelMessages(uiMessages),
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
return result.toUIMessageStreamResponse();
|
|
129
119
|
});
|
|
130
120
|
{{/if}}
|
|
131
121
|
|
|
132
122
|
{{#if (and (includes examples "ai") (eq runtime "workers"))}}
|
|
133
123
|
app.post("/ai", async (c) => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
124
|
+
const body = await c.req.json();
|
|
125
|
+
const uiMessages = body.messages || [];
|
|
126
|
+
const google = createGoogleGenerativeAI({
|
|
127
|
+
apiKey: env.GOOGLE_GENERATIVE_AI_API_KEY,
|
|
128
|
+
});
|
|
129
|
+
const result = streamText({
|
|
130
|
+
model: google("gemini-2.5-flash"),
|
|
131
|
+
messages: convertToModelMessages(uiMessages),
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
return result.toUIMessageStreamResponse();
|
|
145
135
|
});
|
|
146
136
|
{{/if}}
|
|
147
137
|
|
|
148
138
|
app.get("/", (c) => {
|
|
149
|
-
|
|
139
|
+
return c.text("OK");
|
|
150
140
|
});
|
|
151
141
|
|
|
152
142
|
{{#if (eq runtime "node")}}
|
|
153
143
|
import { serve } from "@hono/node-server";
|
|
154
144
|
|
|
155
145
|
serve(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
146
|
+
{
|
|
147
|
+
fetch: app.fetch,
|
|
148
|
+
port: 3000,
|
|
149
|
+
},
|
|
150
|
+
(info) => {
|
|
151
|
+
console.log(`Server is running on http://localhost:${info.port}`);
|
|
152
|
+
}
|
|
163
153
|
);
|
|
164
154
|
{{else}}
|
|
165
155
|
{{#if (eq runtime "bun")}}
|
|
@@ -1,33 +1,26 @@
|
|
|
1
1
|
{{#if (or (eq runtime "bun") (eq runtime "node") (eq runtime "none"))}}
|
|
2
|
-
{
|
|
3
|
-
import dotenv from "dotenv";
|
|
4
|
-
|
|
5
|
-
dotenv.config({
|
|
6
|
-
path: "../../apps/server/.env",
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
{{/if}}
|
|
2
|
+
import { env } from "@{{projectName}}/env/server";
|
|
10
3
|
import * as schema from "./schema";
|
|
11
4
|
|
|
12
5
|
{{#if (eq dbSetup "planetscale")}}
|
|
13
6
|
import { drizzle } from "drizzle-orm/planetscale-serverless";
|
|
14
7
|
|
|
15
8
|
export const db = drizzle({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
connection: {
|
|
10
|
+
host: env.DATABASE_HOST,
|
|
11
|
+
username: env.DATABASE_USERNAME,
|
|
12
|
+
password: env.DATABASE_PASSWORD,
|
|
13
|
+
},
|
|
14
|
+
schema,
|
|
22
15
|
});
|
|
23
16
|
{{else}}
|
|
24
17
|
import { drizzle } from "drizzle-orm/mysql2";
|
|
25
18
|
|
|
26
19
|
export const db = drizzle({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
connection: {
|
|
21
|
+
uri: env.DATABASE_URL,
|
|
22
|
+
},
|
|
23
|
+
schema,
|
|
31
24
|
});
|
|
32
25
|
{{/if}}
|
|
33
26
|
{{/if}}
|
|
@@ -37,25 +30,25 @@ import * as schema from "./schema";
|
|
|
37
30
|
|
|
38
31
|
{{#if (eq dbSetup "planetscale")}}
|
|
39
32
|
import { drizzle } from "drizzle-orm/planetscale-serverless";
|
|
40
|
-
import { env } from "
|
|
33
|
+
import { env } from "@{{projectName}}/env/server";
|
|
41
34
|
|
|
42
35
|
export const db = drizzle({
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
connection: {
|
|
37
|
+
host: env.DATABASE_HOST,
|
|
38
|
+
username: env.DATABASE_USERNAME,
|
|
39
|
+
password: env.DATABASE_PASSWORD,
|
|
40
|
+
},
|
|
41
|
+
schema,
|
|
49
42
|
});
|
|
50
43
|
{{else}}
|
|
51
44
|
import { drizzle } from "drizzle-orm/mysql2";
|
|
52
|
-
import { env } from "
|
|
45
|
+
import { env } from "@{{projectName}}/env/server";
|
|
53
46
|
|
|
54
47
|
export const db = drizzle({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
connection: {
|
|
49
|
+
uri: env.DATABASE_URL,
|
|
50
|
+
},
|
|
51
|
+
schema,
|
|
59
52
|
});
|
|
60
53
|
{{/if}}
|
|
61
54
|
{{/if}}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
{{#if (or (eq runtime "bun") (eq runtime "node") (eq runtime "none"))}}
|
|
2
|
-
{
|
|
3
|
-
import dotenv from "dotenv";
|
|
4
|
-
|
|
5
|
-
dotenv.config({
|
|
6
|
-
path: "../../apps/server/.env",
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
{{/if}}
|
|
2
|
+
import { env } from "@{{projectName}}/env/server";
|
|
10
3
|
import * as schema from "./schema";
|
|
11
4
|
|
|
12
5
|
{{#if (eq dbSetup "neon")}}
|
|
@@ -19,12 +12,12 @@ neonConfig.webSocketConstructor = ws;
|
|
|
19
12
|
// To work in edge environments (Cloudflare Workers, Vercel Edge, etc.), enable querying over fetch
|
|
20
13
|
// neonConfig.poolQueryViaFetch = true
|
|
21
14
|
|
|
22
|
-
const sql = neon(
|
|
15
|
+
const sql = neon(env.DATABASE_URL);
|
|
23
16
|
export const db = drizzle(sql, { schema });
|
|
24
17
|
{{else}}
|
|
25
18
|
import { drizzle } from "drizzle-orm/node-postgres";
|
|
26
19
|
|
|
27
|
-
export const db = drizzle(
|
|
20
|
+
export const db = drizzle(env.DATABASE_URL, { schema });
|
|
28
21
|
{{/if}}
|
|
29
22
|
{{/if}}
|
|
30
23
|
|
|
@@ -34,7 +27,7 @@ import * as schema from "./schema";
|
|
|
34
27
|
{{#if (eq dbSetup "neon")}}
|
|
35
28
|
import { neon, neonConfig } from '@neondatabase/serverless';
|
|
36
29
|
import { drizzle } from 'drizzle-orm/neon-http';
|
|
37
|
-
import { env } from "
|
|
30
|
+
import { env } from "@{{projectName}}/env/server";
|
|
38
31
|
import ws from "ws";
|
|
39
32
|
|
|
40
33
|
neonConfig.webSocketConstructor = ws;
|
|
@@ -44,8 +37,8 @@ const sql = neon(env.DATABASE_URL || "");
|
|
|
44
37
|
export const db = drizzle(sql, { schema });
|
|
45
38
|
{{else}}
|
|
46
39
|
import { drizzle } from "drizzle-orm/node-postgres";
|
|
47
|
-
import { env } from "
|
|
40
|
+
import { env } from "@{{projectName}}/env/server";
|
|
48
41
|
|
|
49
42
|
export const db = drizzle(env.DATABASE_URL || "", { schema });
|
|
50
43
|
{{/if}}
|
|
51
|
-
{{/if}}
|
|
44
|
+
{{/if}}
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
{{#if (or (eq runtime "bun") (eq runtime "node") (eq runtime "none"))}}
|
|
2
|
-
{
|
|
3
|
-
import dotenv from "dotenv";
|
|
4
|
-
|
|
5
|
-
dotenv.config({
|
|
6
|
-
path: "../../apps/server/.env",
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
{{/if}}
|
|
2
|
+
import { env } from "@{{projectName}}/env/server";
|
|
10
3
|
import * as schema from "./schema";
|
|
11
4
|
import { drizzle } from "drizzle-orm/libsql";
|
|
12
5
|
import { createClient } from "@libsql/client";
|
|
13
6
|
|
|
14
7
|
const client = createClient({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
url: env.DATABASE_URL,
|
|
9
|
+
{{#if (eq dbSetup "turso")}}
|
|
10
|
+
authToken: env.DATABASE_AUTH_TOKEN,
|
|
11
|
+
{{/if}}
|
|
19
12
|
});
|
|
20
13
|
|
|
21
14
|
export const db = drizzle({ client, schema });
|
|
@@ -26,19 +19,19 @@ import * as schema from "./schema";
|
|
|
26
19
|
|
|
27
20
|
{{#if (eq dbSetup "d1")}}
|
|
28
21
|
import { drizzle } from "drizzle-orm/d1";
|
|
29
|
-
import { env } from "
|
|
22
|
+
import { env } from "@{{projectName}}/env/server";
|
|
30
23
|
|
|
31
24
|
export const db = drizzle(env.DB, { schema });
|
|
32
25
|
{{else}}
|
|
33
26
|
import { drizzle } from "drizzle-orm/libsql";
|
|
34
|
-
import { env } from "
|
|
27
|
+
import { env } from "@{{projectName}}/env/server";
|
|
35
28
|
import { createClient } from "@libsql/client";
|
|
36
29
|
|
|
37
30
|
const client = createClient({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
url: env.DATABASE_URL || "",
|
|
32
|
+
{{#if (eq dbSetup "turso")}}
|
|
33
|
+
authToken: env.DATABASE_AUTH_TOKEN,
|
|
34
|
+
{{/if}}
|
|
42
35
|
});
|
|
43
36
|
|
|
44
37
|
export const db = drizzle({ client, schema });
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
|
+
import { env } from "@{{projectName}}/env/server";
|
|
2
3
|
|
|
3
|
-
await mongoose.connect(
|
|
4
|
-
|
|
4
|
+
await mongoose.connect(env.DATABASE_URL).catch((error) => {
|
|
5
|
+
console.log("Error connecting to database:", error);
|
|
5
6
|
});
|
|
6
7
|
|
|
7
8
|
const client = mongoose.connection.getClient().db("myDB");
|
|
@@ -8,7 +8,7 @@ generator client {
|
|
|
8
8
|
{{#if (eq runtime "node")}}
|
|
9
9
|
runtime = "nodejs"
|
|
10
10
|
{{/if}}
|
|
11
|
-
{{#if (or (eq runtime "workers") (and (eq backend "self") (eq webDeploy "
|
|
11
|
+
{{#if (or (eq runtime "workers") (and (eq backend "self") (eq webDeploy "cloudflare")))}}
|
|
12
12
|
runtime = "workerd"
|
|
13
13
|
{{/if}}
|
|
14
14
|
}
|
|
@@ -8,7 +8,7 @@ generator client {
|
|
|
8
8
|
{{#if (eq runtime "node")}}
|
|
9
9
|
runtime = "nodejs"
|
|
10
10
|
{{/if}}
|
|
11
|
-
{{#if (or (eq runtime "workers") (and (eq backend "self") (eq webDeploy "
|
|
11
|
+
{{#if (or (eq runtime "workers") (and (eq backend "self") (eq webDeploy "cloudflare")))}}
|
|
12
12
|
runtime = "workerd"
|
|
13
13
|
{{/if}}
|
|
14
14
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { defineConfig, env } from
|
|
3
|
-
import dotenv from
|
|
2
|
+
import { defineConfig, env } from "prisma/config";
|
|
3
|
+
import dotenv from "dotenv";
|
|
4
4
|
|
|
5
5
|
dotenv.config({
|
|
6
|
-
{{#if (eq backend "self")}}
|
|
7
|
-
path: "../../apps/web/.env",
|
|
8
|
-
{{else}}
|
|
9
|
-
path: "../../apps/server/.env",
|
|
10
|
-
{{/if}}
|
|
11
|
-
})
|
|
6
|
+
{{#if (eq backend "self")}}
|
|
7
|
+
path: "../../apps/web/.env",
|
|
8
|
+
{{else}}
|
|
9
|
+
path: "../../apps/server/.env",
|
|
10
|
+
{{/if}}
|
|
11
|
+
});
|
|
12
12
|
|
|
13
13
|
export default defineConfig({
|
|
14
|
-
schema: path.join("prisma", "schema"),
|
|
15
|
-
migrations: {
|
|
16
|
-
path: path.join("prisma", "migrations"),
|
|
17
|
-
},
|
|
18
|
-
datasource: {
|
|
19
|
-
url: env(
|
|
20
|
-
},
|
|
21
|
-
})
|
|
14
|
+
schema: path.join("prisma", "schema"),
|
|
15
|
+
migrations: {
|
|
16
|
+
path: path.join("prisma", "migrations"),
|
|
17
|
+
},
|
|
18
|
+
datasource: {
|
|
19
|
+
url: env("DATABASE_URL"),
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{{#if (eq runtime "workers")}}
|
|
2
2
|
import { PrismaClient } from "../prisma/generated/client";
|
|
3
|
-
import { env } from "
|
|
3
|
+
import { env } from "@{{projectName}}/env/server";
|
|
4
4
|
|
|
5
5
|
{{#if (eq dbSetup "planetscale")}}
|
|
6
6
|
import { PrismaPlanetScale } from "@prisma/adapter-planetscale";
|
|
7
7
|
|
|
8
|
-
const adapter = new PrismaPlanetScale({ url: env.DATABASE_URL
|
|
8
|
+
const adapter = new PrismaPlanetScale({ url: env.DATABASE_URL });
|
|
9
9
|
const prisma = new PrismaClient({ adapter });
|
|
10
10
|
{{else}}
|
|
11
11
|
import { PrismaMariaDb } from "@prisma/adapter-mariadb";
|
|
12
12
|
|
|
13
|
-
const databaseUrl: string = env.DATABASE_URL
|
|
13
|
+
const databaseUrl: string = env.DATABASE_URL;
|
|
14
14
|
const url: URL = new URL(databaseUrl);
|
|
15
15
|
const connectionConfig = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
host: url.hostname,
|
|
17
|
+
port: parseInt(url.port || "3306"),
|
|
18
|
+
user: url.username,
|
|
19
|
+
password: url.password,
|
|
20
|
+
database: url.pathname.slice(1),
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
const adapter = new PrismaMariaDb(connectionConfig);
|
|
@@ -27,23 +27,24 @@ const prisma = new PrismaClient({ adapter });
|
|
|
27
27
|
export default prisma;
|
|
28
28
|
{{else}}
|
|
29
29
|
import { PrismaClient } from "../prisma/generated/client";
|
|
30
|
+
import { env } from "@{{projectName}}/env/server";
|
|
30
31
|
|
|
31
32
|
{{#if (eq dbSetup "planetscale")}}
|
|
32
33
|
import { PrismaPlanetScale } from "@prisma/adapter-planetscale";
|
|
33
34
|
|
|
34
|
-
const adapter = new PrismaPlanetScale({ url:
|
|
35
|
+
const adapter = new PrismaPlanetScale({ url: env.DATABASE_URL });
|
|
35
36
|
const prisma = new PrismaClient({ adapter });
|
|
36
37
|
{{else}}
|
|
37
38
|
import { PrismaMariaDb } from "@prisma/adapter-mariadb";
|
|
38
39
|
|
|
39
|
-
const databaseUrl: string =
|
|
40
|
+
const databaseUrl: string = env.DATABASE_URL;
|
|
40
41
|
const url: URL = new URL(databaseUrl);
|
|
41
42
|
const connectionConfig = {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
host: url.hostname,
|
|
44
|
+
port: parseInt(url.port || "3306"),
|
|
45
|
+
user: url.username,
|
|
46
|
+
password: url.password,
|
|
47
|
+
database: url.pathname.slice(1),
|
|
47
48
|
};
|
|
48
49
|
|
|
49
50
|
const adapter = new PrismaMariaDb(connectionConfig);
|
|
@@ -8,7 +8,7 @@ generator client {
|
|
|
8
8
|
{{#if (eq runtime "node")}}
|
|
9
9
|
runtime = "nodejs"
|
|
10
10
|
{{/if}}
|
|
11
|
-
{{#if (or (eq runtime "workers") (and (eq backend "self") (eq webDeploy "
|
|
11
|
+
{{#if (or (eq runtime "workers") (and (eq backend "self") (eq webDeploy "cloudflare")))}}
|
|
12
12
|
runtime = "workerd"
|
|
13
13
|
{{/if}}
|
|
14
14
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{{#if (eq runtime "workers")}}
|
|
2
2
|
import { PrismaClient } from "../prisma/generated/client";
|
|
3
|
-
import { env } from "
|
|
3
|
+
import { env } from "@{{projectName}}/env/server";
|
|
4
4
|
{{#if (eq dbSetup "neon")}}
|
|
5
5
|
import { PrismaNeon } from "@prisma/adapter-neon";
|
|
6
6
|
import { neonConfig } from "@neondatabase/serverless";
|
|
@@ -8,16 +8,16 @@ import { neonConfig } from "@neondatabase/serverless";
|
|
|
8
8
|
neonConfig.poolQueryViaFetch = true;
|
|
9
9
|
|
|
10
10
|
const prisma = new PrismaClient({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
adapter: new PrismaNeon({
|
|
12
|
+
connectionString: env.DATABASE_URL,
|
|
13
|
+
}),
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
{{else if (eq dbSetup "prisma-postgres")}}
|
|
17
17
|
import { PrismaPg } from "@prisma/adapter-pg";
|
|
18
18
|
|
|
19
19
|
const adapter = new PrismaPg({
|
|
20
|
-
|
|
20
|
+
connectionString: env.DATABASE_URL,
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
const prisma = new PrismaClient({ adapter });
|
|
@@ -25,7 +25,7 @@ const prisma = new PrismaClient({ adapter });
|
|
|
25
25
|
{{else}}
|
|
26
26
|
import { PrismaPg } from "@prisma/adapter-pg";
|
|
27
27
|
|
|
28
|
-
const adapter = new PrismaPg({ connectionString: env.DATABASE_URL
|
|
28
|
+
const adapter = new PrismaPg({ connectionString: env.DATABASE_URL });
|
|
29
29
|
const prisma = new PrismaClient({ adapter });
|
|
30
30
|
|
|
31
31
|
{{/if}}
|
|
@@ -33,6 +33,7 @@ const prisma = new PrismaClient({ adapter });
|
|
|
33
33
|
export default prisma;
|
|
34
34
|
{{else}}
|
|
35
35
|
import { PrismaClient } from "../prisma/generated/client";
|
|
36
|
+
import { env } from "@{{projectName}}/env/server";
|
|
36
37
|
{{#if (eq dbSetup "neon")}}
|
|
37
38
|
import { PrismaNeon } from "@prisma/adapter-neon";
|
|
38
39
|
import { neonConfig } from "@neondatabase/serverless";
|
|
@@ -42,7 +43,7 @@ neonConfig.webSocketConstructor = ws;
|
|
|
42
43
|
neonConfig.poolQueryViaFetch = true;
|
|
43
44
|
|
|
44
45
|
const adapter = new PrismaNeon({
|
|
45
|
-
|
|
46
|
+
connectionString: env.DATABASE_URL,
|
|
46
47
|
});
|
|
47
48
|
|
|
48
49
|
const prisma = new PrismaClient({ adapter });
|
|
@@ -51,7 +52,7 @@ const prisma = new PrismaClient({ adapter });
|
|
|
51
52
|
import { PrismaPg } from "@prisma/adapter-pg";
|
|
52
53
|
|
|
53
54
|
const adapter = new PrismaPg({
|
|
54
|
-
|
|
55
|
+
connectionString: env.DATABASE_URL,
|
|
55
56
|
});
|
|
56
57
|
|
|
57
58
|
const prisma = new PrismaClient({ adapter });
|
|
@@ -59,7 +60,7 @@ const prisma = new PrismaClient({ adapter });
|
|
|
59
60
|
{{else}}
|
|
60
61
|
import { PrismaPg } from "@prisma/adapter-pg";
|
|
61
62
|
|
|
62
|
-
const adapter = new PrismaPg({ connectionString:
|
|
63
|
+
const adapter = new PrismaPg({ connectionString: env.DATABASE_URL });
|
|
63
64
|
const prisma = new PrismaClient({ adapter });
|
|
64
65
|
|
|
65
66
|
{{/if}}
|
|
@@ -8,7 +8,7 @@ generator client {
|
|
|
8
8
|
{{#if (eq runtime "node")}}
|
|
9
9
|
runtime = "nodejs"
|
|
10
10
|
{{/if}}
|
|
11
|
-
{{#if (or (eq runtime "workers") (and (eq backend "self") (eq webDeploy "
|
|
11
|
+
{{#if (or (eq runtime "workers") (and (eq backend "self") (eq webDeploy "cloudflare")))}}
|
|
12
12
|
runtime = "workerd"
|
|
13
13
|
{{/if}}
|
|
14
14
|
}
|
|
@@ -2,7 +2,7 @@ import { PrismaClient } from "../prisma/generated/client";
|
|
|
2
2
|
|
|
3
3
|
{{#if (eq dbSetup "d1")}}
|
|
4
4
|
import { PrismaD1 } from "@prisma/adapter-d1";
|
|
5
|
-
import { env } from "
|
|
5
|
+
import { env } from "@{{projectName}}/env/server";
|
|
6
6
|
|
|
7
7
|
const adapter = new PrismaD1(env.DB);
|
|
8
8
|
const prisma = new PrismaClient({ adapter });
|
|
@@ -10,15 +10,12 @@ const prisma = new PrismaClient({ adapter });
|
|
|
10
10
|
export default prisma;
|
|
11
11
|
{{else}}
|
|
12
12
|
import { PrismaLibSql } from "@prisma/adapter-libsql";
|
|
13
|
-
{
|
|
14
|
-
import { env } from "cloudflare:workers";
|
|
15
|
-
{{/if}}
|
|
13
|
+
import { env } from "@{{projectName}}/env/server";
|
|
16
14
|
|
|
17
15
|
const adapter = new PrismaLibSql({
|
|
18
|
-
url:
|
|
16
|
+
url: env.DATABASE_URL,
|
|
19
17
|
{{#if (eq dbSetup "turso")}}
|
|
20
|
-
authToken:
|
|
21
|
-
""{{/if}},
|
|
18
|
+
authToken: env.DATABASE_AUTH_TOKEN || "",
|
|
22
19
|
{{/if}}
|
|
23
20
|
});
|
|
24
21
|
|