create-better-t-stack 2.50.0 → 2.50.1-canary.7ebd503f
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 +8 -9
- package/dist/index.js +1 -1
- package/dist/{src-BFx0Xu3C.js → src-DG05Vcnx.js} +696 -343
- package/package.json +2 -1
- package/templates/api/orpc/fullstack/next/src/app/api/rpc/[[...rest]]/route.ts.hbs +50 -0
- package/templates/api/orpc/server/_gitignore +34 -0
- package/templates/api/orpc/server/package.json.hbs +24 -0
- package/templates/api/orpc/server/{base/src/lib → src}/context.ts.hbs +6 -6
- package/templates/{backend/server/server-base → api/orpc/server}/src/routers/index.ts.hbs +2 -2
- package/templates/api/orpc/server/tsconfig.json.hbs +10 -0
- package/templates/api/orpc/server/tsdown.config.ts.hbs +7 -0
- 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/_gitignore +34 -0
- package/templates/api/trpc/server/package.json.hbs +23 -0
- package/templates/api/trpc/server/{base/src/lib → src}/context.ts.hbs +6 -6
- package/templates/api/trpc/server/src/routers/index.ts.hbs +55 -0
- package/templates/api/trpc/server/tsconfig.json.hbs +13 -0
- package/templates/api/trpc/server/tsdown.config.ts.hbs +7 -0
- package/templates/api/trpc/web/react/base/src/utils/trpc.ts.hbs +6 -4
- package/templates/auth/better-auth/{server/next/src/app/api/auth/[...all]/route.ts → fullstack/next/src/app/api/auth/[...all]/route.ts.hbs} +1 -1
- package/templates/auth/better-auth/server/base/_gitignore +34 -0
- package/templates/auth/better-auth/server/base/package.json.hbs +24 -0
- package/templates/auth/better-auth/server/base/src/{lib/auth.ts.hbs → index.ts.hbs} +12 -12
- package/templates/auth/better-auth/server/base/tsconfig.json.hbs +13 -0
- package/templates/auth/better-auth/server/base/tsdown.config.ts.hbs +7 -0
- 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/{server-base → base}/package.json.hbs +1 -5
- package/templates/backend/server/{server-base → base}/tsconfig.json.hbs +5 -10
- package/templates/backend/server/base/tsdown.config.ts.hbs +9 -0
- package/templates/backend/server/elysia/src/index.ts.hbs +6 -6
- package/templates/backend/server/express/src/index.ts.hbs +6 -6
- package/templates/backend/server/fastify/src/index.ts.hbs +6 -6
- package/templates/backend/server/hono/src/index.ts.hbs +7 -7
- package/templates/base/_gitignore +47 -1
- package/templates/base/package.json.hbs +1 -3
- package/templates/base/tsconfig.base.json.hbs +23 -0
- package/templates/base/tsconfig.json.hbs +3 -0
- package/templates/db/base/_gitignore +34 -0
- package/templates/db/base/package.json.hbs +23 -0
- package/templates/db/base/tsconfig.json.hbs +13 -0
- package/templates/db/base/tsdown.config.ts.hbs +7 -0
- package/templates/db/drizzle/mysql/drizzle.config.ts.hbs +11 -2
- package/templates/db/drizzle/mysql/src/{db/index.ts.hbs → index.ts.hbs} +1 -1
- package/templates/db/drizzle/postgres/drizzle.config.ts.hbs +11 -2
- package/templates/db/drizzle/postgres/src/{db/index.ts.hbs → index.ts.hbs} +1 -1
- package/templates/db/drizzle/sqlite/drizzle.config.ts.hbs +11 -2
- package/templates/db/drizzle/sqlite/src/{db/index.ts.hbs → index.ts.hbs} +1 -1
- package/templates/db/prisma/mongodb/prisma.config.ts.hbs +9 -1
- package/templates/db/prisma/mongodb/src/index.ts.hbs +5 -0
- package/templates/db/prisma/mysql/prisma.config.ts.hbs +9 -1
- package/templates/db/prisma/mysql/src/{db/index.ts.hbs → index.ts.hbs} +1 -1
- package/templates/db/prisma/postgres/prisma.config.ts.hbs +11 -3
- package/templates/db/prisma/postgres/src/{db/index.ts.hbs → index.ts.hbs} +1 -1
- package/templates/db/prisma/sqlite/prisma.config.ts.hbs +9 -1
- package/templates/db/prisma/sqlite/src/{db/index.ts.hbs → index.ts.hbs} +3 -3
- 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 +6 -6
- package/templates/examples/todo/server/mongoose/base/src/routers/todo.ts.hbs +4 -4
- package/templates/examples/todo/server/prisma/base/src/routers/todo.ts.hbs +4 -4
- 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/api/orpc/server/next/src/app/rpc/[...all]/route.ts.hbs +0 -52
- package/templates/api/trpc/server/next/src/app/trpc/[trpc]/route.ts +0 -14
- package/templates/backend/server/next/next-env.d.ts +0 -5
- package/templates/backend/server/next/next.config.ts +0 -7
- package/templates/backend/server/next/package.json.hbs +0 -27
- package/templates/backend/server/next/src/app/route.ts +0 -5
- package/templates/backend/server/next/src/middleware.ts +0 -19
- package/templates/backend/server/next/tsconfig.json.hbs +0 -33
- package/templates/db/prisma/mongodb/src/db/index.ts.hbs +0 -5
- package/templates/examples/ai/server/next/src/app/ai/route.ts.hbs +0 -15
- /package/templates/api/orpc/server/{base/src/lib/orpc.ts.hbs → src/index.ts.hbs} +0 -0
- /package/templates/api/trpc/server/{base/src/lib/trpc.ts.hbs → src/index.ts.hbs} +0 -0
- /package/templates/auth/better-auth/server/db/drizzle/mysql/src/{db/schema/auth.ts → schema/auth.ts.hbs} +0 -0
- /package/templates/auth/better-auth/server/db/drizzle/postgres/src/{db/schema/auth.ts → schema/auth.ts.hbs} +0 -0
- /package/templates/auth/better-auth/server/db/drizzle/sqlite/src/{db/schema/auth.ts → schema/auth.ts.hbs} +0 -0
- /package/templates/auth/better-auth/server/db/mongoose/mongodb/src/{db/models/auth.model.ts → models/auth.model.ts.hbs} +0 -0
- /package/templates/auth/better-auth/server/db/prisma/mongodb/prisma/schema/{auth.prisma → auth.prisma.hbs} +0 -0
- /package/templates/auth/better-auth/server/db/prisma/mysql/prisma/schema/{auth.prisma → auth.prisma.hbs} +0 -0
- /package/templates/auth/better-auth/server/db/prisma/postgres/prisma/schema/{auth.prisma → auth.prisma.hbs} +0 -0
- /package/templates/auth/better-auth/server/db/prisma/sqlite/prisma/schema/{auth.prisma → auth.prisma.hbs} +0 -0
- /package/templates/auth/better-auth/web/nuxt/app/middleware/{auth.ts → auth.ts.hbs} +0 -0
- /package/templates/backend/server/{server-base → base}/_gitignore +0 -0
- /package/templates/db/mongoose/mongodb/src/{db/index.ts.hbs → index.ts.hbs} +0 -0
- /package/templates/examples/todo/server/drizzle/mysql/src/{db/schema → schema}/todo.ts +0 -0
- /package/templates/examples/todo/server/drizzle/postgres/src/{db/schema → schema}/todo.ts +0 -0
- /package/templates/examples/todo/server/drizzle/sqlite/src/{db/schema → schema}/todo.ts +0 -0
- /package/templates/examples/todo/server/mongoose/mongodb/src/{db/models/todo.model.ts → models/todo.model.ts.hbs} +0 -0
- /package/templates/examples/todo/server/prisma/mongodb/prisma/schema/{todo.prisma → todo.prisma.hbs} +0 -0
- /package/templates/examples/todo/server/prisma/mysql/prisma/schema/{todo.prisma → todo.prisma.hbs} +0 -0
- /package/templates/examples/todo/server/prisma/postgres/prisma/schema/{todo.prisma → todo.prisma.hbs} +0 -0
- /package/templates/examples/todo/server/prisma/sqlite/prisma/schema/{todo.prisma → todo.prisma.hbs} +0 -0
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.7ebd503f",
|
|
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,6 +77,7 @@
|
|
|
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",
|
|
80
81
|
"zod": "^4.1.11"
|
|
81
82
|
},
|
|
82
83
|
"devDependencies": {
|
|
@@ -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;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# dependencies (bun install)
|
|
2
|
+
node_modules
|
|
3
|
+
|
|
4
|
+
# output
|
|
5
|
+
out
|
|
6
|
+
dist
|
|
7
|
+
*.tgz
|
|
8
|
+
|
|
9
|
+
# code coverage
|
|
10
|
+
coverage
|
|
11
|
+
*.lcov
|
|
12
|
+
|
|
13
|
+
# logs
|
|
14
|
+
logs
|
|
15
|
+
_.log
|
|
16
|
+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
|
17
|
+
|
|
18
|
+
# dotenv environment variable files
|
|
19
|
+
.env
|
|
20
|
+
.env.development.local
|
|
21
|
+
.env.test.local
|
|
22
|
+
.env.production.local
|
|
23
|
+
.env.local
|
|
24
|
+
|
|
25
|
+
# caches
|
|
26
|
+
.eslintcache
|
|
27
|
+
.cache
|
|
28
|
+
*.tsbuildinfo
|
|
29
|
+
|
|
30
|
+
# IntelliJ based IDEs
|
|
31
|
+
.idea
|
|
32
|
+
|
|
33
|
+
# Finder (MacOS) folder config
|
|
34
|
+
.DS_Store
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@{{projectName}}/api",
|
|
3
|
+
"exports": {
|
|
4
|
+
".": {
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"default": "./src/index.ts"
|
|
7
|
+
},
|
|
8
|
+
"./*": {
|
|
9
|
+
"types": "./dist/*.d.ts",
|
|
10
|
+
"default": "./src/*.ts"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsdown"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/bun": "latest"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"typescript": "^5"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {}
|
|
24
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
{{#if (eq backend '
|
|
1
|
+
{{#if (and (eq backend 'self') (includes frontend "next"))}}
|
|
2
2
|
import type { NextRequest } from "next/server";
|
|
3
3
|
{{#if (eq auth "better-auth")}}
|
|
4
|
-
import { auth } from "
|
|
4
|
+
import { auth } from "@{{projectName}}/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 "
|
|
23
|
+
import { auth } from "@{{projectName}}/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 "
|
|
49
|
+
import { auth } from "@{{projectName}}/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 "
|
|
75
|
+
import { auth } from "@{{projectName}}/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 "
|
|
98
|
+
import { auth } from "@{{projectName}}/auth";
|
|
99
99
|
{{/if}}
|
|
100
100
|
|
|
101
101
|
export async function createContext(req: IncomingHttpHeaders) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{{#if (eq api "orpc")}}
|
|
2
|
-
import { {{#if (eq auth "better-auth")}}protectedProcedure, {{/if}}publicProcedure } from "../
|
|
2
|
+
import { {{#if (eq auth "better-auth")}}protectedProcedure, {{/if}}publicProcedure } from "../index";
|
|
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 "../
|
|
30
|
+
} from "../index";
|
|
31
31
|
{{#if (includes examples "todo")}}
|
|
32
32
|
import { todoRouter } from "./todo";
|
|
33
33
|
{{/if}}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineNuxtPlugin, useRuntimeConfig } from '#app'
|
|
2
|
-
import type { AppRouterClient } from "
|
|
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 "
|
|
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 "
|
|
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 "
|
|
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 };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# dependencies (bun install)
|
|
2
|
+
node_modules
|
|
3
|
+
|
|
4
|
+
# output
|
|
5
|
+
out
|
|
6
|
+
dist
|
|
7
|
+
*.tgz
|
|
8
|
+
|
|
9
|
+
# code coverage
|
|
10
|
+
coverage
|
|
11
|
+
*.lcov
|
|
12
|
+
|
|
13
|
+
# logs
|
|
14
|
+
logs
|
|
15
|
+
_.log
|
|
16
|
+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
|
17
|
+
|
|
18
|
+
# dotenv environment variable files
|
|
19
|
+
.env
|
|
20
|
+
.env.development.local
|
|
21
|
+
.env.test.local
|
|
22
|
+
.env.production.local
|
|
23
|
+
.env.local
|
|
24
|
+
|
|
25
|
+
# caches
|
|
26
|
+
.eslintcache
|
|
27
|
+
.cache
|
|
28
|
+
*.tsbuildinfo
|
|
29
|
+
|
|
30
|
+
# IntelliJ based IDEs
|
|
31
|
+
.idea
|
|
32
|
+
|
|
33
|
+
# Finder (MacOS) folder config
|
|
34
|
+
.DS_Store
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@{{projectName}}/api",
|
|
3
|
+
"exports": {
|
|
4
|
+
".": {
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"default": "./src/index.ts"
|
|
7
|
+
},
|
|
8
|
+
"./*": {
|
|
9
|
+
"types": "./dist/*.d.ts",
|
|
10
|
+
"default": "./src/*.ts"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsdown"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/bun": "latest"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"typescript": "^5"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
{{#if (eq backend '
|
|
1
|
+
{{#if (and (eq backend 'self') (includes frontend "next"))}}
|
|
2
2
|
import type { NextRequest } from "next/server";
|
|
3
3
|
{{#if (eq auth "better-auth")}}
|
|
4
|
-
import { auth } from "
|
|
4
|
+
import { auth } from "@{{projectName}}/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 "
|
|
26
|
+
import { auth } from "@{{projectName}}/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 "
|
|
52
|
+
import { auth } from "@{{projectName}}/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 "
|
|
79
|
+
import { auth } from "@{{projectName}}/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 "
|
|
102
|
+
import { auth } from "@{{projectName}}/auth";
|
|
103
103
|
{{/if}}
|
|
104
104
|
|
|
105
105
|
export async function createContext({ req, res }: CreateFastifyContextOptions) {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{{#if (eq api "orpc")}}
|
|
2
|
+
import { {{#if (eq auth "better-auth")}}protectedProcedure, {{/if}}publicProcedure } from "../index";
|
|
3
|
+
import type { RouterClient } from "@orpc/server";
|
|
4
|
+
{{#if (includes examples "todo")}}
|
|
5
|
+
import { todoRouter } from "./todo";
|
|
6
|
+
{{/if}}
|
|
7
|
+
|
|
8
|
+
export const appRouter = {
|
|
9
|
+
healthCheck: publicProcedure.handler(() => {
|
|
10
|
+
return "OK";
|
|
11
|
+
}),
|
|
12
|
+
{{#if (eq auth "better-auth")}}
|
|
13
|
+
privateData: protectedProcedure.handler(({ context }) => {
|
|
14
|
+
return {
|
|
15
|
+
message: "This is private",
|
|
16
|
+
user: context.session?.user,
|
|
17
|
+
};
|
|
18
|
+
}),
|
|
19
|
+
{{/if}}
|
|
20
|
+
{{#if (includes examples "todo")}}
|
|
21
|
+
todo: todoRouter,
|
|
22
|
+
{{/if}}
|
|
23
|
+
};
|
|
24
|
+
export type AppRouter = typeof appRouter;
|
|
25
|
+
export type AppRouterClient = RouterClient<typeof appRouter>;
|
|
26
|
+
{{else if (eq api "trpc")}}
|
|
27
|
+
import {
|
|
28
|
+
{{#if (eq auth "better-auth")}}protectedProcedure, {{/if}}publicProcedure,
|
|
29
|
+
router,
|
|
30
|
+
} from "../index";
|
|
31
|
+
{{#if (includes examples "todo")}}
|
|
32
|
+
import { todoRouter } from "./todo";
|
|
33
|
+
{{/if}}
|
|
34
|
+
|
|
35
|
+
export const appRouter = router({
|
|
36
|
+
healthCheck: publicProcedure.query(() => {
|
|
37
|
+
return "OK";
|
|
38
|
+
}),
|
|
39
|
+
{{#if (eq auth "better-auth")}}
|
|
40
|
+
privateData: protectedProcedure.query(({ ctx }) => {
|
|
41
|
+
return {
|
|
42
|
+
message: "This is private",
|
|
43
|
+
user: ctx.session.user,
|
|
44
|
+
};
|
|
45
|
+
}),
|
|
46
|
+
{{/if}}
|
|
47
|
+
{{#if (includes examples "todo")}}
|
|
48
|
+
todo: todoRouter,
|
|
49
|
+
{{/if}}
|
|
50
|
+
});
|
|
51
|
+
export type AppRouter = typeof appRouter;
|
|
52
|
+
{{else}}
|
|
53
|
+
export const appRouter = {};
|
|
54
|
+
export type AppRouter = typeof appRouter;
|
|
55
|
+
{{/if}}
|
|
@@ -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 "
|
|
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 "
|
|
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";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# dependencies (bun install)
|
|
2
|
+
node_modules
|
|
3
|
+
|
|
4
|
+
# output
|
|
5
|
+
out
|
|
6
|
+
dist
|
|
7
|
+
*.tgz
|
|
8
|
+
|
|
9
|
+
# code coverage
|
|
10
|
+
coverage
|
|
11
|
+
*.lcov
|
|
12
|
+
|
|
13
|
+
# logs
|
|
14
|
+
logs
|
|
15
|
+
_.log
|
|
16
|
+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
|
17
|
+
|
|
18
|
+
# dotenv environment variable files
|
|
19
|
+
.env
|
|
20
|
+
.env.development.local
|
|
21
|
+
.env.test.local
|
|
22
|
+
.env.production.local
|
|
23
|
+
.env.local
|
|
24
|
+
|
|
25
|
+
# caches
|
|
26
|
+
.eslintcache
|
|
27
|
+
.cache
|
|
28
|
+
*.tsbuildinfo
|
|
29
|
+
|
|
30
|
+
# IntelliJ based IDEs
|
|
31
|
+
.idea
|
|
32
|
+
|
|
33
|
+
# Finder (MacOS) folder config
|
|
34
|
+
.DS_Store
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@{{projectName}}/auth",
|
|
3
|
+
"exports": {
|
|
4
|
+
".": {
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"default": "./src/index.ts"
|
|
7
|
+
},
|
|
8
|
+
"./*": {
|
|
9
|
+
"types": "./dist/*.d.ts",
|
|
10
|
+
"default": "./src/*.ts"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsdown"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/bun": "latest",
|
|
19
|
+
"@types/node": "^24.5.2"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"typescript": "^5"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -6,9 +6,9 @@ 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
|
-
import prisma from "
|
|
11
|
+
import prisma from "@{{projectName}}/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"))}}
|
|
69
|
+
{{#if (or (eq runtime "bun") (eq runtime "node") (eq runtime "none"))}}
|
|
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"))}}
|
|
@@ -74,10 +74,10 @@ 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
|
-
import { db } from "
|
|
80
|
-
import * as schema from "
|
|
79
|
+
import { db } from "@{{projectName}}/db";
|
|
80
|
+
import * as schema from "@{{projectName}}/db/schema/auth";
|
|
81
81
|
|
|
82
82
|
export const auth = betterAuth<BetterAuthOptions>({
|
|
83
83
|
database: drizzleAdapter(db, {
|
|
@@ -142,10 +142,10 @@ 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
|
-
import { db } from "
|
|
148
|
-
import * as schema from "
|
|
147
|
+
import { db } from "@{{projectName}}/db";
|
|
148
|
+
import * as schema from "@{{projectName}}/db/schema/auth";
|
|
149
149
|
import { env } from "cloudflare:workers";
|
|
150
150
|
|
|
151
151
|
export const auth = betterAuth<BetterAuthOptions>({
|
|
@@ -224,9 +224,9 @@ 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
|
-
import { client } from "
|
|
229
|
+
import { client } from "@{{projectName}}/db";
|
|
230
230
|
|
|
231
231
|
export const auth = betterAuth<BetterAuthOptions>({
|
|
232
232
|
database: mongodbAdapter(client),
|
|
@@ -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>({
|