create-better-t-stack 2.50.0-canary.dd7000f2 → 2.50.1-canary.58bbe5f6
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 +6 -7
- package/dist/index.js +1 -1
- package/dist/{src-dv6H37db.js → src-CulfT5QB.js} +461 -358
- package/package.json +1 -1
- package/templates/addons/ruler/.ruler/bts.md.hbs +24 -14
- package/templates/api/orpc/fullstack/next/src/app/api/rpc/[[...rest]]/route.ts.hbs +50 -0
- package/templates/api/orpc/server/package.json.hbs +1 -3
- package/templates/api/orpc/server/tsconfig.json.hbs +8 -8
- package/templates/api/orpc/web/nuxt/app/plugins/orpc.ts.hbs +1 -1
- package/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs +4 -2
- package/templates/api/orpc/web/solid/src/utils/orpc.ts.hbs +1 -1
- package/templates/api/orpc/web/svelte/src/lib/orpc.ts.hbs +1 -1
- package/templates/api/trpc/fullstack/next/src/app/api/trpc/[trpc]/route.ts.hbs +14 -0
- package/templates/api/trpc/server/package.json.hbs +1 -3
- package/templates/api/trpc/server/tsconfig.json.hbs +8 -11
- package/templates/api/trpc/web/react/base/src/utils/trpc.ts.hbs +6 -4
- package/templates/auth/better-auth/fullstack/next/src/app/api/auth/[...all]/route.ts.hbs +4 -0
- package/templates/auth/better-auth/server/base/package.json.hbs +1 -4
- package/templates/auth/better-auth/server/base/src/index.ts.hbs +5 -5
- package/templates/auth/better-auth/server/base/tsconfig.json.hbs +8 -11
- package/templates/auth/better-auth/web/react/base/src/lib/auth-client.ts.hbs +2 -0
- package/templates/auth/better-auth/web/react/next/src/app/dashboard/page.tsx.hbs +31 -0
- package/templates/backend/server/base/package.json.hbs +1 -4
- package/templates/backend/server/base/tsconfig.json.hbs +1 -15
- package/templates/backend/server/base/tsdown.config.ts.hbs +1 -6
- package/templates/base/tsconfig.base.json.hbs +34 -0
- package/templates/base/tsconfig.json.hbs +3 -0
- package/templates/db/base/package.json.hbs +1 -3
- package/templates/db/base/tsconfig.json.hbs +8 -11
- package/templates/db/drizzle/mysql/drizzle.config.ts.hbs +5 -1
- package/templates/db/drizzle/postgres/drizzle.config.ts.hbs +5 -1
- package/templates/db/drizzle/sqlite/drizzle.config.ts.hbs +5 -1
- package/templates/db/prisma/mongodb/prisma.config.ts.hbs +5 -1
- package/templates/db/prisma/mysql/prisma.config.ts.hbs +5 -1
- package/templates/db/prisma/postgres/prisma.config.ts.hbs +5 -1
- package/templates/db/prisma/sqlite/prisma.config.ts.hbs +5 -1
- package/templates/deploy/alchemy/alchemy.run.ts.hbs +3 -3
- package/templates/examples/ai/fullstack/next/src/app/api/ai/route.ts.hbs +15 -0
- package/templates/examples/todo/server/drizzle/base/src/routers/todo.ts.hbs +2 -2
- package/templates/frontend/native/nativewind/tsconfig.json.hbs +1 -6
- package/templates/frontend/native/unistyles/tsconfig.json.hbs +1 -6
- package/templates/frontend/nuxt/tsconfig.json.hbs +0 -4
- package/templates/frontend/react/next/package.json.hbs +1 -1
- package/templates/frontend/react/next/tsconfig.json.hbs +0 -7
- package/templates/frontend/react/react-router/tsconfig.json.hbs +1 -6
- package/templates/frontend/react/tanstack-router/src/routes/__root.tsx.hbs +1 -1
- package/templates/frontend/react/tanstack-router/tsconfig.json.hbs +1 -6
- package/templates/frontend/react/tanstack-start/src/routes/__root.tsx.hbs +1 -1
- package/templates/frontend/react/tanstack-start/tsconfig.json.hbs +1 -6
- package/templates/frontend/solid/tsconfig.json.hbs +1 -6
- package/templates/frontend/svelte/tsconfig.json.hbs +1 -6
- package/templates/base/tsconfig.base.json +0 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-better-t-stack",
|
|
3
|
-
"version": "2.50.
|
|
3
|
+
"version": "2.50.1-canary.58bbe5f6",
|
|
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",
|
|
@@ -8,14 +8,14 @@ This is a monorepo with the following structure:
|
|
|
8
8
|
|
|
9
9
|
{{#if (or (includes frontend "tanstack-router") (includes frontend "react-router") (includes frontend "tanstack-start")
|
|
10
10
|
(includes frontend "next") (includes frontend "nuxt") (includes frontend "svelte") (includes frontend "solid"))}}
|
|
11
|
-
- **`apps/web/`** - Frontend application{{#if (includes frontend "tanstack-router")}} (React with TanStack Router){{else
|
|
11
|
+
- **`apps/web/`** - {{#if (eq backend "self")}}Fullstack application{{else}}Frontend application{{/if}}{{#if (includes frontend "tanstack-router")}} (React with TanStack Router){{else
|
|
12
12
|
if (includes frontend "react-router")}} (React with React Router){{else if (includes frontend "next")}} (Next.js){{else
|
|
13
13
|
if (includes frontend "nuxt")}} (Nuxt.js){{else if (includes frontend "svelte")}} (SvelteKit){{else if (includes
|
|
14
14
|
frontend "solid")}} (SolidStart){{/if}}
|
|
15
15
|
{{/if}}
|
|
16
16
|
|
|
17
17
|
{{#if (ne backend "convex")}}
|
|
18
|
-
{{#if (ne backend "none")}}
|
|
18
|
+
{{#if (and (ne backend "none") (ne backend "self"))}}
|
|
19
19
|
- **`apps/server/`** - Backend server{{#if (eq backend "hono")}} (Hono){{else if (eq backend "express")}}
|
|
20
20
|
(Express){{else if (eq backend "fastify")}} (Fastify){{else if (eq backend "elysia")}} (Elysia){{else if (eq backend
|
|
21
21
|
"next")}} (Next.js API){{/if}}
|
|
@@ -24,6 +24,18 @@ frontend "solid")}} (SolidStart){{/if}}
|
|
|
24
24
|
- **`packages/backend/`** - Convex backend functions
|
|
25
25
|
{{/if}}
|
|
26
26
|
|
|
27
|
+
{{#if (or (ne backend "none") (ne backend "convex"))}}
|
|
28
|
+
{{#if (ne api "none")}}
|
|
29
|
+
- **`packages/api/`** - Shared API logic and types
|
|
30
|
+
{{/if}}
|
|
31
|
+
{{#if (and (ne auth "none") (ne backend "convex"))}}
|
|
32
|
+
- **`packages/auth/`** - Authentication logic and utilities
|
|
33
|
+
{{/if}}
|
|
34
|
+
{{#if (and (ne database "none") (ne orm "none") (ne backend "convex"))}}
|
|
35
|
+
- **`packages/db/`** - Database schema and utilities
|
|
36
|
+
{{/if}}
|
|
37
|
+
{{/if}}
|
|
38
|
+
|
|
27
39
|
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
|
28
40
|
- **`apps/native/`** - React Native mobile app{{#if (includes frontend "native-nativewind")}} (with NativeWind){{else if
|
|
29
41
|
(includes frontend "native-unistyles")}} (with Unistyles){{/if}}
|
|
@@ -32,15 +44,13 @@ frontend "solid")}} (SolidStart){{/if}}
|
|
|
32
44
|
## Available Scripts
|
|
33
45
|
|
|
34
46
|
- `{{packageManager}} run dev` - Start all apps in development mode
|
|
35
|
-
{{#if (or (includes frontend "tanstack-router") (includes frontend "react-router") (includes frontend "tanstack-start")
|
|
36
|
-
(includes frontend "next") (includes frontend "nuxt") (includes frontend "svelte") (includes frontend "solid"))}}
|
|
47
|
+
{{#if (and (or (includes frontend "tanstack-router") (includes frontend "react-router") (includes frontend "tanstack-start")
|
|
48
|
+
(includes frontend "next") (includes frontend "nuxt") (includes frontend "svelte") (includes frontend "solid")) (ne backend "self"))}}
|
|
37
49
|
- `{{packageManager}} run dev:web` - Start only the web app
|
|
38
50
|
{{/if}}
|
|
39
|
-
{{#if (ne backend "none")}}
|
|
40
|
-
{{#if (ne backend "convex")}}
|
|
51
|
+
{{#if (and (ne backend "none") (ne backend "convex") (ne backend "self"))}}
|
|
41
52
|
- `{{packageManager}} run dev:server` - Start only the server
|
|
42
53
|
{{/if}}
|
|
43
|
-
{{/if}}
|
|
44
54
|
{{#if (or (includes frontend "native-nativewind") (includes frontend "native-unistyles"))}}
|
|
45
55
|
- `{{packageManager}} run dev:native` - Start only the native app
|
|
46
56
|
{{/if}}
|
|
@@ -48,7 +58,7 @@ frontend "solid")}} (SolidStart){{/if}}
|
|
|
48
58
|
{{#if (and (ne database "none") (ne orm "none") (ne backend "convex"))}}
|
|
49
59
|
## Database Commands
|
|
50
60
|
|
|
51
|
-
All database operations should be run from the server workspace:
|
|
61
|
+
All database operations should be run from the {{#if (eq backend "self")}}web{{else}}server{{/if}} workspace:
|
|
52
62
|
|
|
53
63
|
- `{{packageManager}} run db:push` - Push schema changes to database
|
|
54
64
|
- `{{packageManager}} run db:studio` - Open database studio
|
|
@@ -57,11 +67,11 @@ All database operations should be run from the server workspace:
|
|
|
57
67
|
- `{{packageManager}} run db:migrate` - Run database migrations
|
|
58
68
|
|
|
59
69
|
{{#if (eq orm "drizzle")}}
|
|
60
|
-
Database schema files are located in `apps/server/src/db/schema/`
|
|
70
|
+
Database schema files are located in {{#if (eq backend "self")}}`apps/web/src/db/schema/`{{else}}`apps/server/src/db/schema/`{{/if}}
|
|
61
71
|
{{else if (eq orm "prisma")}}
|
|
62
|
-
Database schema is located in `apps/server/prisma/schema.prisma`
|
|
72
|
+
Database schema is located in {{#if (eq backend "self")}}`apps/web/prisma/schema.prisma`{{else}}`apps/server/prisma/schema.prisma`{{/if}}
|
|
63
73
|
{{else if (eq orm "mongoose")}}
|
|
64
|
-
Database models are located in `apps/server/src/db/models/`
|
|
74
|
+
Database models are located in {{#if (eq backend "self")}}`apps/web/src/db/models/`{{else}}`apps/server/src/db/models/`{{/if}}
|
|
65
75
|
{{/if}}
|
|
66
76
|
{{/if}}
|
|
67
77
|
|
|
@@ -69,10 +79,10 @@ Database models are located in `apps/server/src/db/models/`
|
|
|
69
79
|
## API Structure
|
|
70
80
|
|
|
71
81
|
{{#if (eq api "trpc")}}
|
|
72
|
-
- tRPC routers are in `apps/server/src/routers/`
|
|
82
|
+
- tRPC routers are in {{#if (eq backend "self")}}`packages/api/src/routers/`{{else}}`apps/server/src/routers/`{{/if}}
|
|
73
83
|
- Client-side tRPC utils are in `apps/web/src/utils/trpc.ts`
|
|
74
84
|
{{else if (eq api "orpc")}}
|
|
75
|
-
- oRPC endpoints are in `apps/server/src/api/`
|
|
85
|
+
- oRPC endpoints are in {{#if (eq backend "self")}}`packages/api/src/api/`{{else}}`apps/server/src/api/`{{/if}}
|
|
76
86
|
- Client-side API utils are in `apps/web/src/utils/api.ts`
|
|
77
87
|
{{/if}}
|
|
78
88
|
{{/if}}
|
|
@@ -82,7 +92,7 @@ Database models are located in `apps/server/src/db/models/`
|
|
|
82
92
|
|
|
83
93
|
Authentication is enabled in this project:
|
|
84
94
|
{{#if (ne backend "convex")}}
|
|
85
|
-
- Server auth logic is in `apps/server/src/lib/auth.ts`
|
|
95
|
+
- Server auth logic is in {{#if (eq backend "self")}}`packages/auth/src/lib/auth.ts`{{else}}`apps/server/src/lib/auth.ts`{{/if}}
|
|
86
96
|
{{#if (or (includes frontend "tanstack-router") (includes frontend "react-router") (includes frontend "tanstack-start")
|
|
87
97
|
(includes frontend "next") (includes frontend "nuxt") (includes frontend "svelte") (includes frontend "solid"))}}
|
|
88
98
|
- Web app auth client is in `apps/web/src/lib/auth-client.ts`
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createContext } from "@{{projectName}}/api/context";
|
|
2
|
+
import { appRouter } from "@{{projectName}}/api/routers/index";
|
|
3
|
+
import { OpenAPIHandler } from "@orpc/openapi/fetch";
|
|
4
|
+
import { OpenAPIReferencePlugin } from "@orpc/openapi/plugins";
|
|
5
|
+
import { ZodToJsonSchemaConverter } from "@orpc/zod/zod4";
|
|
6
|
+
import { RPCHandler } from "@orpc/server/fetch";
|
|
7
|
+
import { onError } from "@orpc/server";
|
|
8
|
+
import { NextRequest } from "next/server";
|
|
9
|
+
|
|
10
|
+
const rpcHandler = new RPCHandler(appRouter, {
|
|
11
|
+
interceptors: [
|
|
12
|
+
onError((error) => {
|
|
13
|
+
console.error(error);
|
|
14
|
+
}),
|
|
15
|
+
],
|
|
16
|
+
});
|
|
17
|
+
const apiHandler = new OpenAPIHandler(appRouter, {
|
|
18
|
+
plugins: [
|
|
19
|
+
new OpenAPIReferencePlugin({
|
|
20
|
+
schemaConverters: [new ZodToJsonSchemaConverter()],
|
|
21
|
+
}),
|
|
22
|
+
],
|
|
23
|
+
interceptors: [
|
|
24
|
+
onError((error) => {
|
|
25
|
+
console.error(error);
|
|
26
|
+
}),
|
|
27
|
+
],
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
async function handleRequest(req: NextRequest) {
|
|
31
|
+
const rpcResult = await rpcHandler.handle(req, {
|
|
32
|
+
prefix: "/api/rpc",
|
|
33
|
+
context: await createContext(req),
|
|
34
|
+
});
|
|
35
|
+
if (rpcResult.response) return rpcResult.response;
|
|
36
|
+
|
|
37
|
+
const apiResult = await apiHandler.handle(req, {
|
|
38
|
+
prefix: "/api/rpc/api",
|
|
39
|
+
context: await createContext(req),
|
|
40
|
+
});
|
|
41
|
+
if (apiResult.response) return apiResult.response;
|
|
42
|
+
|
|
43
|
+
return new Response("Not found", { status: 404 });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const GET = handleRequest;
|
|
47
|
+
export const POST = handleRequest;
|
|
48
|
+
export const PUT = handleRequest;
|
|
49
|
+
export const PATCH = handleRequest;
|
|
50
|
+
export const DELETE = handleRequest;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"declarationMap": true,
|
|
6
|
+
"sourceMap": true,
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"composite": true
|
|
9
|
+
}
|
|
10
10
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineNuxtPlugin, useRuntimeConfig } from '#app'
|
|
2
|
-
import type { AppRouterClient } from "@{{projectName}}/api/
|
|
2
|
+
import type { AppRouterClient } from "@{{projectName}}/api/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/
|
|
6
|
+
import type { AppRouterClient } from "@{{projectName}}/api/routers/index";
|
|
7
7
|
|
|
8
8
|
export const queryClient = new QueryClient({
|
|
9
9
|
queryCache: new QueryCache({
|
|
@@ -21,7 +21,9 @@ export const queryClient = new QueryClient({
|
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
export const link = new RPCLink({
|
|
24
|
-
{{#if (includes frontend "next")}}
|
|
24
|
+
{{#if (and (eq backend "self") (includes frontend "next"))}}
|
|
25
|
+
url: `${typeof window !== "undefined" ? window.location.origin : "http://localhost:3001"}/api/rpc`,
|
|
26
|
+
{{else if (includes frontend "next")}}
|
|
25
27
|
url: `${process.env.NEXT_PUBLIC_SERVER_URL}/rpc`,
|
|
26
28
|
{{else}}
|
|
27
29
|
url: `${import.meta.env.VITE_SERVER_URL}/rpc`,
|
|
@@ -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/
|
|
5
|
+
import type { AppRouterClient } from "@{{projectName}}/api/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/
|
|
6
|
+
import type { AppRouterClient } from "@{{projectName}}/api/routers/index";
|
|
7
7
|
|
|
8
8
|
export const queryClient = new QueryClient({
|
|
9
9
|
queryCache: new QueryCache({
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
|
|
2
|
+
import { appRouter } from "@{{projectName}}/api/routers/index";
|
|
3
|
+
import { createContext } from "@{{projectName}}/api/context";
|
|
4
|
+
import { NextRequest } from "next/server";
|
|
5
|
+
|
|
6
|
+
function handler(req: NextRequest) {
|
|
7
|
+
return fetchRequestHandler({
|
|
8
|
+
endpoint: "/api/trpc",
|
|
9
|
+
req,
|
|
10
|
+
router: appRouter,
|
|
11
|
+
createContext: () => createContext(req),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export { handler as GET, handler as POST };
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"bun"
|
|
11
|
-
]
|
|
12
|
-
}
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"declarationMap": true,
|
|
6
|
+
"sourceMap": true,
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"composite": true
|
|
9
|
+
}
|
|
13
10
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { QueryCache, QueryClient } from '@tanstack/react-query';
|
|
3
3
|
import { createTRPCClient, httpBatchLink } from '@trpc/client';
|
|
4
4
|
import { createTRPCOptionsProxy } from '@trpc/tanstack-react-query';
|
|
5
|
-
import type { AppRouter } from
|
|
5
|
+
import type { AppRouter } from "@{{projectName}}/api/routers/index";
|
|
6
6
|
import { toast } from 'sonner';
|
|
7
7
|
|
|
8
8
|
export const queryClient = new QueryClient({
|
|
@@ -23,7 +23,9 @@ export const queryClient = new QueryClient({
|
|
|
23
23
|
const trpcClient = createTRPCClient<AppRouter>({
|
|
24
24
|
links: [
|
|
25
25
|
httpBatchLink({
|
|
26
|
-
{{#if (includes frontend 'next')}}
|
|
26
|
+
{{#if (and (eq backend "self") (includes frontend 'next'))}}
|
|
27
|
+
url: "/api/trpc",
|
|
28
|
+
{{else if (includes frontend 'next')}}
|
|
27
29
|
url: `${process.env.NEXT_PUBLIC_SERVER_URL}/trpc`,
|
|
28
30
|
{{else}}
|
|
29
31
|
url: `${import.meta.env.VITE_SERVER_URL}/trpc`,
|
|
@@ -47,13 +49,13 @@ export const trpc = createTRPCOptionsProxy<AppRouter>({
|
|
|
47
49
|
|
|
48
50
|
{{else if (includes frontend 'tanstack-start')}}
|
|
49
51
|
import { createTRPCContext } from "@trpc/tanstack-react-query";
|
|
50
|
-
import type { AppRouter } from "@{{projectName}}/api/
|
|
52
|
+
import type { AppRouter } from "@{{projectName}}/api/routers/index";
|
|
51
53
|
|
|
52
54
|
export const { TRPCProvider, useTRPC, useTRPCClient } =
|
|
53
55
|
createTRPCContext<AppRouter>();
|
|
54
56
|
|
|
55
57
|
{{else}}
|
|
56
|
-
import type { AppRouter } from "@{{projectName}}/api/
|
|
58
|
+
import type { AppRouter } from "@{{projectName}}/api/routers/index";
|
|
57
59
|
import { QueryCache, QueryClient } from "@tanstack/react-query";
|
|
58
60
|
import { createTRPCClient, httpBatchLink } from "@trpc/client";
|
|
59
61
|
import { createTRPCOptionsProxy } from "@trpc/tanstack-react-query";
|
|
@@ -6,7 +6,7 @@ import { expo } from "@better-auth/expo";
|
|
|
6
6
|
{{/if}}
|
|
7
7
|
{{#if (eq payments "polar")}}
|
|
8
8
|
import { polar, checkout, portal } from "@polar-sh/better-auth";
|
|
9
|
-
import { polarClient } from "./payments";
|
|
9
|
+
import { polarClient } from "./lib/payments";
|
|
10
10
|
{{/if}}
|
|
11
11
|
import prisma from "@{{projectName}}/db";
|
|
12
12
|
|
|
@@ -74,7 +74,7 @@ import { expo } from "@better-auth/expo";
|
|
|
74
74
|
{{/if}}
|
|
75
75
|
{{#if (eq payments "polar")}}
|
|
76
76
|
import { polar, checkout, portal } from "@polar-sh/better-auth";
|
|
77
|
-
import { polarClient } from "./payments";
|
|
77
|
+
import { polarClient } from "./lib/payments";
|
|
78
78
|
{{/if}}
|
|
79
79
|
import { db } from "@{{projectName}}/db";
|
|
80
80
|
import * as schema from "@{{projectName}}/db/schema/auth";
|
|
@@ -142,7 +142,7 @@ import { expo } from "@better-auth/expo";
|
|
|
142
142
|
{{/if}}
|
|
143
143
|
{{#if (eq payments "polar")}}
|
|
144
144
|
import { polar, checkout, portal } from "@polar-sh/better-auth";
|
|
145
|
-
import { polarClient } from "./payments";
|
|
145
|
+
import { polarClient } from "./lib/payments";
|
|
146
146
|
{{/if}}
|
|
147
147
|
import { db } from "@{{projectName}}/db";
|
|
148
148
|
import * as schema from "@{{projectName}}/db/schema/auth";
|
|
@@ -224,7 +224,7 @@ import { expo } from "@better-auth/expo";
|
|
|
224
224
|
{{/if}}
|
|
225
225
|
{{#if (eq payments "polar")}}
|
|
226
226
|
import { polar, checkout, portal } from "@polar-sh/better-auth";
|
|
227
|
-
import { polarClient } from "./payments";
|
|
227
|
+
import { polarClient } from "./lib/payments";
|
|
228
228
|
{{/if}}
|
|
229
229
|
import { client } from "@{{projectName}}/db";
|
|
230
230
|
|
|
@@ -285,7 +285,7 @@ import { expo } from "@better-auth/expo";
|
|
|
285
285
|
{{/if}}
|
|
286
286
|
{{#if (eq payments "polar")}}
|
|
287
287
|
import { polar, checkout, portal } from "@polar-sh/better-auth";
|
|
288
|
-
import { polarClient } from "./payments";
|
|
288
|
+
import { polarClient } from "./lib/payments";
|
|
289
289
|
{{/if}}
|
|
290
290
|
|
|
291
291
|
export const auth = betterAuth<BetterAuthOptions>({
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"bun"
|
|
11
|
-
]
|
|
12
|
-
}
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"declarationMap": true,
|
|
6
|
+
"sourceMap": true,
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"composite": true
|
|
9
|
+
}
|
|
13
10
|
}
|
|
@@ -4,12 +4,14 @@ import { polarClient } from "@polar-sh/better-auth";
|
|
|
4
4
|
{{/if}}
|
|
5
5
|
|
|
6
6
|
export const authClient = createAuthClient({
|
|
7
|
+
{{#unless (eq backend "self")}}
|
|
7
8
|
baseURL:
|
|
8
9
|
{{#if (includes frontend "next")}}
|
|
9
10
|
process.env.NEXT_PUBLIC_SERVER_URL,
|
|
10
11
|
{{else}}
|
|
11
12
|
import.meta.env.VITE_SERVER_URL,
|
|
12
13
|
{{/if}}
|
|
14
|
+
{{/unless}}
|
|
13
15
|
{{#if (eq payments "polar")}}
|
|
14
16
|
plugins: [polarClient()]
|
|
15
17
|
{{/if}}
|
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
{{#if (eq backend "self")}}
|
|
2
|
+
import { redirect } from "next/navigation";
|
|
3
|
+
import Dashboard from "./dashboard";
|
|
4
|
+
import { headers } from "next/headers";
|
|
5
|
+
import { auth } from "@{{projectName}}/auth";
|
|
6
|
+
|
|
7
|
+
export default async function DashboardPage() {
|
|
8
|
+
const session = await auth.api.getSession({
|
|
9
|
+
headers: await headers(),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
if (!session?.user) {
|
|
13
|
+
redirect("/login");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
{{#if (eq payments "polar")}}
|
|
17
|
+
const { data: customerState } = await auth.api.customer.state({
|
|
18
|
+
headers: await headers(),
|
|
19
|
+
});
|
|
20
|
+
{{/if}}
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div>
|
|
24
|
+
<h1>Dashboard</h1>
|
|
25
|
+
<p>Welcome {session.user.name}</p>
|
|
26
|
+
<Dashboard session={session} {{#if (eq payments "polar")}}customerState={customerState}{{/if}} />
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
{{else}}
|
|
1
31
|
import { authClient } from "@/lib/auth-client";
|
|
2
32
|
import { redirect } from "next/navigation";
|
|
3
33
|
import Dashboard from "./dashboard";
|
|
@@ -35,3 +65,4 @@ export default async function DashboardPage() {
|
|
|
35
65
|
</div>
|
|
36
66
|
);
|
|
37
67
|
}
|
|
68
|
+
{{/if}}
|
|
@@ -7,10 +7,7 @@
|
|
|
7
7
|
"check-types": "tsc -b",
|
|
8
8
|
"compile": "bun build --compile --minify --sourcemap --bytecode ./src/index.ts --outfile server"
|
|
9
9
|
},
|
|
10
|
-
"dependencies": {
|
|
11
|
-
"dotenv": "^17.2.1",
|
|
12
|
-
"zod": "^4.0.2"
|
|
13
|
-
},
|
|
10
|
+
"dependencies": {},
|
|
14
11
|
{{#if (eq dbSetup 'supabase')}}
|
|
15
12
|
"trustedDependencies": [
|
|
16
13
|
"supabase"
|
|
@@ -5,22 +5,8 @@
|
|
|
5
5
|
"outDir": "dist",
|
|
6
6
|
"baseUrl": ".",
|
|
7
7
|
"paths": {
|
|
8
|
-
"@/*": ["./src/*"]
|
|
9
|
-
"prisma": ["node_modules/prisma"]{{/if}}
|
|
8
|
+
"@/*": ["./src/*"]
|
|
10
9
|
},
|
|
11
|
-
"types": [
|
|
12
|
-
{{#if (eq runtime "node")}}
|
|
13
|
-
"node"
|
|
14
|
-
{{else if (eq runtime "bun")}}
|
|
15
|
-
"bun"
|
|
16
|
-
{{else if (eq runtime "workers")}}
|
|
17
|
-
"node"
|
|
18
|
-
{{else}}
|
|
19
|
-
"node",
|
|
20
|
-
"bun"
|
|
21
|
-
{{/if}}{{#if (eq serverDeploy "alchemy")}},
|
|
22
|
-
"@cloudflare/workers-types"{{/if}}
|
|
23
|
-
],
|
|
24
10
|
"jsx": "react-jsx"{{#if (eq backend "hono")}},
|
|
25
11
|
"jsxImportSource": "hono/jsx"{{/if}}
|
|
26
12
|
}
|
|
@@ -5,10 +5,5 @@ export default defineConfig({
|
|
|
5
5
|
format: 'esm',
|
|
6
6
|
outDir: './dist',
|
|
7
7
|
clean: true,
|
|
8
|
-
noExternal: [/@{{projectName}}\/.*/]
|
|
9
|
-
{{#if (and (eq orm "drizzle") (eq database "sqlite") (or (eq dbSetup "turso") (eq dbSetup "none")))}}
|
|
10
|
-
external: [
|
|
11
|
-
/^@libsql\/(linux|darwin|win32).*/
|
|
12
|
-
]
|
|
13
|
-
{{/if}}
|
|
8
|
+
noExternal: [/@{{projectName}}\/.*/]
|
|
14
9
|
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "ESNext",
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"lib": ["ESNext"],
|
|
8
|
+
"verbatimModuleSyntax": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
"allowSyntheticDefaultImports": true,
|
|
13
|
+
"esModuleInterop": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"isolatedModules": true,
|
|
16
|
+
"noUncheckedIndexedAccess": true,
|
|
17
|
+
"noUnusedLocals": true,
|
|
18
|
+
"noUnusedParameters": true,
|
|
19
|
+
"noFallthroughCasesInSwitch": true,
|
|
20
|
+
"types": [
|
|
21
|
+
{{#if (eq runtime "node")}}
|
|
22
|
+
"node"
|
|
23
|
+
{{else if (eq runtime "bun")}}
|
|
24
|
+
"bun"
|
|
25
|
+
{{else if (eq runtime "workers")}}
|
|
26
|
+
"node"
|
|
27
|
+
{{else}}
|
|
28
|
+
"node",
|
|
29
|
+
"bun"
|
|
30
|
+
{{/if}}{{#if (eq serverDeploy "alchemy")}},
|
|
31
|
+
"@cloudflare/workers-types"{{/if}}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"bun"
|
|
11
|
-
]
|
|
12
|
-
}
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"declarationMap": true,
|
|
6
|
+
"sourceMap": true,
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"composite": true
|
|
9
|
+
}
|
|
13
10
|
}
|
|
@@ -2,7 +2,11 @@ import { defineConfig } from "drizzle-kit";
|
|
|
2
2
|
import dotenv from "dotenv";
|
|
3
3
|
|
|
4
4
|
dotenv.config({
|
|
5
|
-
|
|
5
|
+
{{#if (eq backend "self")}}
|
|
6
|
+
path: "../../apps/web/.env",
|
|
7
|
+
{{else}}
|
|
8
|
+
path: "../../apps/server/.env",
|
|
9
|
+
{{/if}}
|
|
6
10
|
});
|
|
7
11
|
|
|
8
12
|
export default defineConfig({
|
|
@@ -2,7 +2,11 @@ import { defineConfig } from "drizzle-kit";
|
|
|
2
2
|
import dotenv from "dotenv";
|
|
3
3
|
|
|
4
4
|
dotenv.config({
|
|
5
|
-
|
|
5
|
+
{{#if (eq backend "self")}}
|
|
6
|
+
path: "../../apps/web/.env",
|
|
7
|
+
{{else}}
|
|
8
|
+
path: "../../apps/server/.env",
|
|
9
|
+
{{/if}}
|
|
6
10
|
});
|
|
7
11
|
|
|
8
12
|
export default defineConfig({
|
|
@@ -2,7 +2,11 @@ import { defineConfig } from "drizzle-kit";
|
|
|
2
2
|
import dotenv from "dotenv";
|
|
3
3
|
|
|
4
4
|
dotenv.config({
|
|
5
|
-
|
|
5
|
+
{{#if (eq backend "self")}}
|
|
6
|
+
path: "../../apps/web/.env",
|
|
7
|
+
{{else}}
|
|
8
|
+
path: "../../apps/server/.env",
|
|
9
|
+
{{/if}}
|
|
6
10
|
});
|
|
7
11
|
|
|
8
12
|
export default defineConfig({
|
|
@@ -3,7 +3,11 @@ import type { PrismaConfig } from "prisma";
|
|
|
3
3
|
import dotenv from "dotenv";
|
|
4
4
|
|
|
5
5
|
dotenv.config({
|
|
6
|
-
|
|
6
|
+
{{#if (eq backend "self")}}
|
|
7
|
+
path: "../../apps/web/.env",
|
|
8
|
+
{{else}}
|
|
9
|
+
path: "../../apps/server/.env",
|
|
10
|
+
{{/if}}
|
|
7
11
|
});
|
|
8
12
|
|
|
9
13
|
export default {
|