create-better-t-stack 2.40.3 → 2.40.4-canary.f07be855
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.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/{src-BOnnM-3r.js → src-BMkTBm89.js} +328 -85
- package/package.json +1 -1
- package/templates/api/orpc/server/next/src/app/rpc/[...all]/route.ts.hbs +32 -3
- package/templates/auth/better-auth/server/base/src/lib/auth.ts.hbs +1 -1
- package/templates/backend/server/elysia/src/index.ts.hbs +31 -2
- package/templates/backend/server/express/src/index.ts.hbs +38 -4
- package/templates/backend/server/fastify/src/index.ts.hbs +33 -2
- package/templates/backend/server/hono/src/index.ts.hbs +40 -5
- package/templates/db/drizzle/mysql/src/db/index.ts.hbs +25 -0
- package/templates/db/prisma/mongodb/src/db/index.ts.hbs +5 -0
- package/templates/db/prisma/mysql/prisma/schema/schema.prisma.hbs +6 -0
- package/templates/db/prisma/mysql/src/db/index.ts.hbs +12 -0
- package/templates/db/prisma/postgres/prisma/schema/schema.prisma.hbs +3 -0
- package/templates/db/prisma/postgres/src/db/index.ts.hbs +5 -0
- package/templates/db/prisma/sqlite/prisma/schema/schema.prisma.hbs +10 -0
- package/templates/db/prisma/sqlite/prisma.config.ts.hbs +29 -1
- package/templates/db/prisma/sqlite/src/db/index.ts.hbs +28 -0
- package/templates/deploy/alchemy/alchemy.run.ts.hbs +6 -2
- package/templates/deploy/wrangler/server/wrangler.jsonc.hbs +5 -0
- package/templates/examples/todo/server/prisma/base/src/routers/todo.ts.hbs +2 -2
- package/templates/extras/bunfig.toml.hbs +0 -5
- package/templates/frontend/react/next/next.config.ts.hbs +7 -0
- package/templates/db/prisma/mongodb/prisma/index.ts.hbs +0 -5
- package/templates/db/prisma/mysql/prisma/index.ts +0 -5
- package/templates/db/prisma/postgres/prisma/index.ts +0 -5
- package/templates/db/prisma/sqlite/prisma/index.ts +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-better-t-stack",
|
|
3
|
-
"version": "2.40.
|
|
3
|
+
"version": "2.40.4-canary.f07be855",
|
|
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",
|
|
@@ -2,18 +2,47 @@
|
|
|
2
2
|
import { createContext } from '@/lib/context'
|
|
3
3
|
{{/if}}
|
|
4
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'
|
|
5
8
|
import { RPCHandler } from '@orpc/server/fetch'
|
|
9
|
+
import { onError } from '@orpc/server'
|
|
6
10
|
import { NextRequest } from 'next/server'
|
|
7
11
|
|
|
8
|
-
const
|
|
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
|
+
})
|
|
9
31
|
|
|
10
32
|
async function handleRequest(req: NextRequest) {
|
|
11
|
-
const
|
|
33
|
+
const rpcResult = await rpcHandler.handle(req, {
|
|
12
34
|
prefix: '/rpc',
|
|
13
35
|
context: {{#if (eq auth "better-auth")}}await createContext(req){{else}}{}{{/if}},
|
|
14
36
|
})
|
|
37
|
+
if (rpcResult.response) return rpcResult.response
|
|
15
38
|
|
|
16
|
-
|
|
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 })
|
|
17
46
|
}
|
|
18
47
|
|
|
19
48
|
export const GET = handleRequest
|
|
@@ -4,7 +4,7 @@ import { prismaAdapter } from "better-auth/adapters/prisma";
|
|
|
4
4
|
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
|
5
5
|
import { expo } from "@better-auth/expo";
|
|
6
6
|
{{/if}}
|
|
7
|
-
import prisma from "
|
|
7
|
+
import prisma from "@/db";
|
|
8
8
|
|
|
9
9
|
export const auth = betterAuth({
|
|
10
10
|
database: prismaAdapter(prisma, {
|
|
@@ -10,7 +10,11 @@ import { appRouter } from "./routers/index";
|
|
|
10
10
|
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
|
|
11
11
|
{{/if}}
|
|
12
12
|
{{#if (eq api "orpc")}}
|
|
13
|
+
import { OpenAPIHandler } from "@orpc/openapi/fetch";
|
|
14
|
+
import { OpenAPIReferencePlugin } from "@orpc/openapi/plugins";
|
|
15
|
+
import { ZodToJsonSchemaConverter } from "@orpc/zod/zod4";
|
|
13
16
|
import { RPCHandler } from "@orpc/server/fetch";
|
|
17
|
+
import { onError } from "@orpc/server";
|
|
14
18
|
import { appRouter } from "./routers";
|
|
15
19
|
import { createContext } from "./lib/context";
|
|
16
20
|
{{/if}}
|
|
@@ -19,7 +23,25 @@ import { auth } from "./lib/auth";
|
|
|
19
23
|
{{/if}}
|
|
20
24
|
|
|
21
25
|
{{#if (eq api "orpc")}}
|
|
22
|
-
const
|
|
26
|
+
const rpcHandler = new RPCHandler(appRouter, {
|
|
27
|
+
interceptors: [
|
|
28
|
+
onError((error) => {
|
|
29
|
+
console.error(error);
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
});
|
|
33
|
+
const apiHandler = new OpenAPIHandler(appRouter, {
|
|
34
|
+
plugins: [
|
|
35
|
+
new OpenAPIReferencePlugin({
|
|
36
|
+
schemaConverters: [new ZodToJsonSchemaConverter()],
|
|
37
|
+
}),
|
|
38
|
+
],
|
|
39
|
+
interceptors: [
|
|
40
|
+
onError((error) => {
|
|
41
|
+
console.error(error);
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
});
|
|
23
45
|
{{/if}}
|
|
24
46
|
|
|
25
47
|
{{#if (eq runtime "node")}}
|
|
@@ -48,12 +70,19 @@ const app = new Elysia()
|
|
|
48
70
|
{{/if}}
|
|
49
71
|
{{#if (eq api "orpc")}}
|
|
50
72
|
.all('/rpc*', async (context) => {
|
|
51
|
-
const { response } = await
|
|
73
|
+
const { response } = await rpcHandler.handle(context.request, {
|
|
52
74
|
prefix: '/rpc',
|
|
53
75
|
context: await createContext({ context })
|
|
54
76
|
})
|
|
55
77
|
return response ?? new Response('Not Found', { status: 404 })
|
|
56
78
|
})
|
|
79
|
+
.all('/api*', async (context) => {
|
|
80
|
+
const { response } = await apiHandler.handle(context.request, {
|
|
81
|
+
prefix: '/api',
|
|
82
|
+
context: await createContext({ context })
|
|
83
|
+
})
|
|
84
|
+
return response ?? new Response('Not Found', { status: 404 })
|
|
85
|
+
})
|
|
57
86
|
{{/if}}
|
|
58
87
|
{{#if (eq api "trpc")}}
|
|
59
88
|
.all("/trpc/*", async (context) => {
|
|
@@ -5,7 +5,11 @@ import { createContext } from "./lib/context";
|
|
|
5
5
|
import { appRouter } from "./routers/index";
|
|
6
6
|
{{/if}}
|
|
7
7
|
{{#if (eq api "orpc")}}
|
|
8
|
+
import { OpenAPIHandler } from "@orpc/openapi/node";
|
|
9
|
+
import { OpenAPIReferencePlugin } from "@orpc/openapi/plugins";
|
|
10
|
+
import { ZodToJsonSchemaConverter } from "@orpc/zod/zod4";
|
|
8
11
|
import { RPCHandler } from "@orpc/server/node";
|
|
12
|
+
import { onError } from "@orpc/server";
|
|
9
13
|
import { appRouter } from "./routers";
|
|
10
14
|
{{#if (eq auth "better-auth")}}
|
|
11
15
|
import { createContext } from "./lib/context";
|
|
@@ -50,9 +54,28 @@ app.use(
|
|
|
50
54
|
{{/if}}
|
|
51
55
|
|
|
52
56
|
{{#if (eq api "orpc")}}
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
const rpcHandler = new RPCHandler(appRouter, {
|
|
58
|
+
interceptors: [
|
|
59
|
+
onError((error) => {
|
|
60
|
+
console.error(error);
|
|
61
|
+
}),
|
|
62
|
+
],
|
|
63
|
+
});
|
|
64
|
+
const apiHandler = new OpenAPIHandler(appRouter, {
|
|
65
|
+
plugins: [
|
|
66
|
+
new OpenAPIReferencePlugin({
|
|
67
|
+
schemaConverters: [new ZodToJsonSchemaConverter()],
|
|
68
|
+
}),
|
|
69
|
+
],
|
|
70
|
+
interceptors: [
|
|
71
|
+
onError((error) => {
|
|
72
|
+
console.error(error);
|
|
73
|
+
}),
|
|
74
|
+
],
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
app.use(async (req, res, next) => {
|
|
78
|
+
const rpcResult = await rpcHandler.handle(req, res, {
|
|
56
79
|
prefix: "/rpc",
|
|
57
80
|
{{#if (eq auth "better-auth")}}
|
|
58
81
|
context: await createContext({ req }),
|
|
@@ -60,7 +83,18 @@ app.use("/rpc{*path}", async (req, res, next) => {
|
|
|
60
83
|
context: {},
|
|
61
84
|
{{/if}}
|
|
62
85
|
});
|
|
63
|
-
if (matched) return;
|
|
86
|
+
if (rpcResult.matched) return;
|
|
87
|
+
|
|
88
|
+
const apiResult = await apiHandler.handle(req, res, {
|
|
89
|
+
prefix: "/api",
|
|
90
|
+
{{#if (eq auth "better-auth")}}
|
|
91
|
+
context: await createContext({ req }),
|
|
92
|
+
{{else}}
|
|
93
|
+
context: {},
|
|
94
|
+
{{/if}}
|
|
95
|
+
});
|
|
96
|
+
if (apiResult.matched) return;
|
|
97
|
+
|
|
64
98
|
next();
|
|
65
99
|
});
|
|
66
100
|
{{/if}}
|
|
@@ -9,8 +9,12 @@ import { appRouter, type AppRouter } from "./routers/index";
|
|
|
9
9
|
{{/if}}
|
|
10
10
|
|
|
11
11
|
{{#if (eq api "orpc")}}
|
|
12
|
+
import { OpenAPIHandler } from "@orpc/openapi/node";
|
|
13
|
+
import { OpenAPIReferencePlugin } from "@orpc/openapi/plugins";
|
|
14
|
+
import { ZodToJsonSchemaConverter } from "@orpc/zod/zod4";
|
|
12
15
|
import { RPCHandler } from "@orpc/server/node";
|
|
13
16
|
import { CORSPlugin } from "@orpc/server/plugins";
|
|
17
|
+
import { onError } from "@orpc/server";
|
|
14
18
|
import { appRouter } from "./routers/index";
|
|
15
19
|
import { createServer } from "node:http";
|
|
16
20
|
{{#if (eq auth "better-auth")}}
|
|
@@ -40,7 +44,7 @@ const baseCorsConfig = {
|
|
|
40
44
|
};
|
|
41
45
|
|
|
42
46
|
{{#if (eq api "orpc")}}
|
|
43
|
-
const
|
|
47
|
+
const rpcHandler = new RPCHandler(appRouter, {
|
|
44
48
|
plugins: [
|
|
45
49
|
new CORSPlugin({
|
|
46
50
|
origin: process.env.CORS_ORIGIN,
|
|
@@ -48,13 +52,31 @@ const handler = new RPCHandler(appRouter, {
|
|
|
48
52
|
allowHeaders: ["Content-Type", "Authorization"],
|
|
49
53
|
}),
|
|
50
54
|
],
|
|
55
|
+
interceptors: [
|
|
56
|
+
onError((error) => {
|
|
57
|
+
console.error(error);
|
|
58
|
+
}),
|
|
59
|
+
],
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const apiHandler = new OpenAPIHandler(appRouter, {
|
|
63
|
+
plugins: [
|
|
64
|
+
new OpenAPIReferencePlugin({
|
|
65
|
+
schemaConverters: [new ZodToJsonSchemaConverter()],
|
|
66
|
+
}),
|
|
67
|
+
],
|
|
68
|
+
interceptors: [
|
|
69
|
+
onError((error) => {
|
|
70
|
+
console.error(error);
|
|
71
|
+
}),
|
|
72
|
+
],
|
|
51
73
|
});
|
|
52
74
|
|
|
53
75
|
const fastify = Fastify({
|
|
54
76
|
logger: true,
|
|
55
77
|
serverFactory: (fastifyHandler) => {
|
|
56
78
|
const server = createServer(async (req, res) => {
|
|
57
|
-
const { matched } = await
|
|
79
|
+
const { matched } = await rpcHandler.handle(req, res, {
|
|
58
80
|
context: await createContext(req.headers),
|
|
59
81
|
prefix: "/rpc",
|
|
60
82
|
});
|
|
@@ -63,6 +85,15 @@ const fastify = Fastify({
|
|
|
63
85
|
return;
|
|
64
86
|
}
|
|
65
87
|
|
|
88
|
+
const apiResult = await apiHandler.handle(req, res, {
|
|
89
|
+
context: await createContext(req.headers),
|
|
90
|
+
prefix: "/api",
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
if (apiResult.matched) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
66
97
|
fastifyHandler(req, res);
|
|
67
98
|
});
|
|
68
99
|
|
|
@@ -5,7 +5,11 @@ import "dotenv/config";
|
|
|
5
5
|
import { env } from "cloudflare:workers";
|
|
6
6
|
{{/if}}
|
|
7
7
|
{{#if (eq api "orpc")}}
|
|
8
|
+
import { OpenAPIHandler } from "@orpc/openapi/fetch";
|
|
9
|
+
import { OpenAPIReferencePlugin } from "@orpc/openapi/plugins";
|
|
10
|
+
import { ZodToJsonSchemaConverter } from "@orpc/zod/zod4";
|
|
8
11
|
import { RPCHandler } from "@orpc/server/fetch";
|
|
12
|
+
import { onError } from "@orpc/server";
|
|
9
13
|
import { createContext } from "./lib/context";
|
|
10
14
|
import { appRouter } from "./routers/index";
|
|
11
15
|
{{/if}}
|
|
@@ -54,17 +58,48 @@ app.on(["POST", "GET"], "/api/auth/**", (c) => auth.handler(c.req.raw));
|
|
|
54
58
|
{{/if}}
|
|
55
59
|
|
|
56
60
|
{{#if (eq api "orpc")}}
|
|
57
|
-
const
|
|
58
|
-
|
|
61
|
+
export const apiHandler = new OpenAPIHandler(appRouter, {
|
|
62
|
+
plugins: [
|
|
63
|
+
new OpenAPIReferencePlugin({
|
|
64
|
+
schemaConverters: [new ZodToJsonSchemaConverter()],
|
|
65
|
+
}),
|
|
66
|
+
],
|
|
67
|
+
interceptors: [
|
|
68
|
+
onError((error) => {
|
|
69
|
+
console.error(error);
|
|
70
|
+
}),
|
|
71
|
+
],
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export const rpcHandler = new RPCHandler(appRouter, {
|
|
75
|
+
interceptors: [
|
|
76
|
+
onError((error) => {
|
|
77
|
+
console.error(error);
|
|
78
|
+
}),
|
|
79
|
+
],
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
app.use("/*", async (c, next) => {
|
|
59
83
|
const context = await createContext({ context: c });
|
|
60
|
-
|
|
84
|
+
|
|
85
|
+
const rpcResult = await rpcHandler.handle(c.req.raw, {
|
|
61
86
|
prefix: "/rpc",
|
|
62
87
|
context: context,
|
|
63
88
|
});
|
|
64
89
|
|
|
65
|
-
if (matched) {
|
|
66
|
-
return c.newResponse(response.body, response);
|
|
90
|
+
if (rpcResult.matched) {
|
|
91
|
+
return c.newResponse(rpcResult.response.body, rpcResult.response);
|
|
67
92
|
}
|
|
93
|
+
|
|
94
|
+
const apiResult = await apiHandler.handle(c.req.raw, {
|
|
95
|
+
prefix: "/api",
|
|
96
|
+
context: context,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
if (apiResult.matched) {
|
|
100
|
+
return c.newResponse(apiResult.response.body, apiResult.response);
|
|
101
|
+
}
|
|
102
|
+
|
|
68
103
|
await next();
|
|
69
104
|
});
|
|
70
105
|
{{/if}}
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
{{#if (or (eq runtime "bun") (eq runtime "node"))}}
|
|
2
|
+
{{#if (eq dbSetup "planetscale")}}
|
|
3
|
+
import { drizzle } from "drizzle-orm/planetscale-serverless";
|
|
4
|
+
|
|
5
|
+
export const db = drizzle({
|
|
6
|
+
connection: {
|
|
7
|
+
host: process.env.DATABASE_HOST,
|
|
8
|
+
username: process.env.DATABASE_USERNAME,
|
|
9
|
+
password: process.env.DATABASE_PASSWORD,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
{{else}}
|
|
2
13
|
import { drizzle } from "drizzle-orm/mysql2";
|
|
3
14
|
|
|
4
15
|
export const db = drizzle({
|
|
@@ -7,8 +18,21 @@ export const db = drizzle({
|
|
|
7
18
|
},
|
|
8
19
|
});
|
|
9
20
|
{{/if}}
|
|
21
|
+
{{/if}}
|
|
10
22
|
|
|
11
23
|
{{#if (eq runtime "workers")}}
|
|
24
|
+
{{#if (eq dbSetup "planetscale")}}
|
|
25
|
+
import { drizzle } from "drizzle-orm/planetscale-serverless";
|
|
26
|
+
import { env } from "cloudflare:workers";
|
|
27
|
+
|
|
28
|
+
export const db = drizzle({
|
|
29
|
+
connection: {
|
|
30
|
+
host: env.DATABASE_HOST,
|
|
31
|
+
username: env.DATABASE_USERNAME,
|
|
32
|
+
password: env.DATABASE_PASSWORD,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
{{else}}
|
|
12
36
|
import { drizzle } from "drizzle-orm/mysql2";
|
|
13
37
|
import { env } from "cloudflare:workers";
|
|
14
38
|
|
|
@@ -18,3 +42,4 @@ export const db = drizzle({
|
|
|
18
42
|
},
|
|
19
43
|
});
|
|
20
44
|
{{/if}}
|
|
45
|
+
{{/if}}
|
|
@@ -11,9 +11,15 @@ generator client {
|
|
|
11
11
|
{{#if (eq runtime "workers")}}
|
|
12
12
|
runtime = "workerd"
|
|
13
13
|
{{/if}}
|
|
14
|
+
{{#if (eq dbSetup "planetscale")}}
|
|
15
|
+
previewFeatures = ["driverAdapters"]
|
|
16
|
+
{{/if}}
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
datasource db {
|
|
17
20
|
provider = "mysql"
|
|
18
21
|
url = env("DATABASE_URL")
|
|
22
|
+
{{#if (eq dbSetup "planetscale")}}
|
|
23
|
+
relationMode = "prisma"
|
|
24
|
+
{{/if}}
|
|
19
25
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PrismaClient } from "../../prisma/generated/client";
|
|
2
|
+
{{#if (eq dbSetup "planetscale")}}
|
|
3
|
+
import { PrismaPlanetScale } from '@prisma/adapter-planetscale'
|
|
4
|
+
import { fetch as undiciFetch } from 'undici'
|
|
5
|
+
|
|
6
|
+
const adapter = new PrismaPlanetScale({ url: process.env.DATABASE_URL, fetch: undiciFetch })
|
|
7
|
+
const prisma = new PrismaClient({adapter});
|
|
8
|
+
{{else}}
|
|
9
|
+
const prisma = new PrismaClient();
|
|
10
|
+
{{/if}}
|
|
11
|
+
|
|
12
|
+
export default prisma;
|
|
@@ -10,10 +10,20 @@ generator client {
|
|
|
10
10
|
{{/if}}
|
|
11
11
|
{{#if (eq runtime "workers")}}
|
|
12
12
|
runtime = "workerd"
|
|
13
|
+
{{#if (eq dbSetup "d1")}}
|
|
14
|
+
previewFeatures = ["driverAdapters"]
|
|
15
|
+
{{/if}}
|
|
16
|
+
{{/if}}
|
|
17
|
+
{{#if (eq dbSetup "turso")}}
|
|
18
|
+
previewFeatures = ["driverAdapters"]
|
|
13
19
|
{{/if}}
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
datasource db {
|
|
17
23
|
provider = "sqlite"
|
|
24
|
+
{{#if (eq dbSetup "turso")}}
|
|
25
|
+
url = "file:./local.db"
|
|
26
|
+
{{else}}
|
|
18
27
|
url = env("DATABASE_URL")
|
|
28
|
+
{{/if}}
|
|
19
29
|
}
|
|
@@ -1,10 +1,38 @@
|
|
|
1
1
|
import "dotenv/config";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import type { PrismaConfig } from "prisma";
|
|
4
|
+
{{#if (eq dbSetup "d1")}}
|
|
5
|
+
import { PrismaD1 } from "@prisma/adapter-d1";
|
|
6
|
+
{{/if}}
|
|
7
|
+
{{#if (eq dbSetup "turso")}}
|
|
8
|
+
import { PrismaLibSQL } from "@prisma/adapter-libsql";
|
|
9
|
+
{{/if}}
|
|
4
10
|
|
|
5
11
|
export default {
|
|
12
|
+
{{#if (or (eq dbSetup "d1") (eq dbSetup "turso"))}}
|
|
13
|
+
experimental: {
|
|
14
|
+
adapter: true
|
|
15
|
+
},
|
|
16
|
+
{{/if}}
|
|
6
17
|
schema: path.join("prisma", "schema"),
|
|
7
18
|
migrations: {
|
|
8
19
|
path: path.join("prisma", "migrations"),
|
|
9
|
-
}
|
|
20
|
+
},
|
|
21
|
+
{{#if (eq dbSetup "d1")}}
|
|
22
|
+
async adapter() {
|
|
23
|
+
return new PrismaD1({
|
|
24
|
+
CLOUDFLARE_D1_TOKEN: process.env.CLOUDFLARE_D1_TOKEN!,
|
|
25
|
+
CLOUDFLARE_ACCOUNT_ID: process.env.CLOUDFLARE_ACCOUNT_ID!,
|
|
26
|
+
CLOUDFLARE_DATABASE_ID: process.env.CLOUDFLARE_DATABASE_ID!,
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
{{/if}}
|
|
30
|
+
{{#if (eq dbSetup "turso")}}
|
|
31
|
+
async adapter() {
|
|
32
|
+
return new PrismaLibSQL({
|
|
33
|
+
url: process.env.DATABASE_URL || "",
|
|
34
|
+
authToken: process.env.DATABASE_AUTH_TOKEN,
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
{{/if}}
|
|
10
38
|
} satisfies PrismaConfig;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{{#if (eq dbSetup "d1")}}
|
|
2
|
+
import { env } from "cloudflare:workers";
|
|
3
|
+
import { PrismaD1 } from "@prisma/adapter-d1";
|
|
4
|
+
import { PrismaClient } from "../../prisma/generated/client";
|
|
5
|
+
|
|
6
|
+
const adapter = new PrismaD1(env.DB);
|
|
7
|
+
const prisma = new PrismaClient({ adapter });
|
|
8
|
+
|
|
9
|
+
export default prisma;
|
|
10
|
+
{{else if (eq dbSetup "turso")}}
|
|
11
|
+
import { PrismaLibSQL } from "@prisma/adapter-libsql";
|
|
12
|
+
import { PrismaClient } from "../../prisma/generated/client";
|
|
13
|
+
|
|
14
|
+
const adapter = new PrismaLibSQL({
|
|
15
|
+
url: process.env.DATABASE_URL || "",
|
|
16
|
+
authToken: process.env.DATABASE_AUTH_TOKEN,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const prisma = new PrismaClient({ adapter });
|
|
20
|
+
|
|
21
|
+
export default prisma;
|
|
22
|
+
{{else}}
|
|
23
|
+
import { PrismaClient } from "../../prisma/generated/client";
|
|
24
|
+
|
|
25
|
+
const prisma = new PrismaClient();
|
|
26
|
+
|
|
27
|
+
export default prisma;
|
|
28
|
+
{{/if}}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import alchemy from "alchemy";
|
|
2
2
|
{{#if (eq webDeploy "alchemy")}}
|
|
3
3
|
{{#if (includes frontend "next")}}
|
|
4
|
-
import {
|
|
4
|
+
import { Nextjs } from "alchemy/cloudflare";
|
|
5
5
|
{{else if (includes frontend "nuxt")}}
|
|
6
6
|
import { Nuxt } from "alchemy/cloudflare";
|
|
7
7
|
{{else if (includes frontend "svelte")}}
|
|
@@ -44,13 +44,17 @@ await Exec("db-generate", {
|
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
const db = await D1Database("database", {
|
|
47
|
+
{{#if (eq orm "prisma")}}
|
|
48
|
+
migrationsDir: "apps/server/prisma/migrations",
|
|
49
|
+
{{else if (eq orm "drizzle")}}
|
|
47
50
|
migrationsDir: "apps/server/src/db/migrations",
|
|
51
|
+
{{/if}}
|
|
48
52
|
});
|
|
49
53
|
{{/if}}
|
|
50
54
|
|
|
51
55
|
{{#if (eq webDeploy "alchemy")}}
|
|
52
56
|
{{#if (includes frontend "next")}}
|
|
53
|
-
export const web = await
|
|
57
|
+
export const web = await Nextjs("web", {
|
|
54
58
|
{{#if (eq serverDeploy "alchemy")}}cwd: "apps/web",{{/if}}
|
|
55
59
|
bindings: {
|
|
56
60
|
{{#if (eq backend "convex")}}
|
|
@@ -27,7 +27,12 @@
|
|
|
27
27
|
"database_name": "YOUR_DB_NAME",
|
|
28
28
|
"database_id": "YOUR_DB_ID",
|
|
29
29
|
"preview_database_id": "local-test-db",
|
|
30
|
+
{{#if (eq orm "drizzle")}}
|
|
30
31
|
"migrations_dir": "./src/db/migrations"
|
|
32
|
+
{{/if}}
|
|
33
|
+
{{#if (eq orm "prisma")}}
|
|
34
|
+
"migrations_dir": "./prisma/migrations"
|
|
35
|
+
{{/if}}
|
|
31
36
|
}
|
|
32
37
|
]
|
|
33
38
|
{{/if}}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{{#if (eq api "orpc")}}
|
|
2
2
|
import z from "zod";
|
|
3
|
-
import prisma from "
|
|
3
|
+
import prisma from "@/db";
|
|
4
4
|
import { publicProcedure } from "../lib/orpc";
|
|
5
5
|
|
|
6
6
|
export const todoRouter = {
|
|
@@ -52,7 +52,7 @@ export const todoRouter = {
|
|
|
52
52
|
{{#if (eq api "trpc")}}
|
|
53
53
|
import { TRPCError } from "@trpc/server";
|
|
54
54
|
import z from "zod";
|
|
55
|
-
import prisma from "
|
|
55
|
+
import prisma from "@/db";
|
|
56
56
|
import { publicProcedure, router } from "../lib/trpc";
|
|
57
57
|
|
|
58
58
|
export const todoRouter = router({
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
{{#if (or (eq webDeploy "alchemy") (eq webDeploy "wrangler"))}}
|
|
2
|
+
import { initOpenNextCloudflareForDev } from "@opennextjs/cloudflare";
|
|
3
|
+
{{/if}}
|
|
1
4
|
import type { NextConfig } from "next";
|
|
2
5
|
|
|
3
6
|
const nextConfig: NextConfig = {
|
|
@@ -5,3 +8,7 @@ const nextConfig: NextConfig = {
|
|
|
5
8
|
};
|
|
6
9
|
|
|
7
10
|
export default nextConfig;
|
|
11
|
+
|
|
12
|
+
{{#if (or (eq webDeploy "alchemy") (eq webDeploy "wrangler"))}}
|
|
13
|
+
initOpenNextCloudflareForDev();
|
|
14
|
+
{{/if}}
|