Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/loud-carrots-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": minor
---

rename index.ts to \_app.ts
6 changes: 2 additions & 4 deletions cli/src/installers/trpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ export const trpcInstaller: Installer = ({ projectDir, packages }) => {
"src/server/trpc/router/auth.ts",
);

const indexRouterFile = usingAuth
? "auth-index-router.ts"
: "index-router.ts";
const indexRouterFile = usingAuth ? "auth-app-router.ts" : "app-router.ts";
const indexRouterSrc = path.join(trpcAssetDir, indexRouterFile);
const indexRouterDest = path.join(
projectDir,
"src/server/trpc/router/index.ts",
"src/server/trpc/router/_app.ts",
);

const exampleRouterFile = usingPrisma
Expand Down
2 changes: 1 addition & 1 deletion cli/template/addons/trpc/api-handler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// src/pages/api/trpc/[trpc].ts
import { createNextApiHandler } from "@trpc/server/adapters/next";
import { appRouter } from "../../../server/trpc/router";
import { appRouter } from "../../../server/trpc/router/_app";
import { createContext } from "../../../server/trpc/context";
import { env } from "../../../env/server.mjs";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/server/router/index.ts
// src/server/router/_app.ts
import { router } from "../trpc";

import { exampleRouter } from "./example";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/server/trpc/router/index.ts
// src/server/trpc/router/_app.ts
import { router } from "../trpc";
import { exampleRouter } from "./example";
import { authRouter } from "./auth";
Expand Down
2 changes: 1 addition & 1 deletion cli/template/addons/trpc/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// src/utils/trpc.ts
import { httpBatchLink, loggerLink } from "@trpc/client";
import { createTRPCNext } from "@trpc/next";
import type { AppRouter } from "../server/trpc/router";
import type { AppRouter } from "../server/trpc/router/_app";
import superjson from "superjson";

const getBaseUrl = () => {
Expand Down
2 changes: 1 addition & 1 deletion www/src/pages/en/usage/trpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ What does this snippet do? It's a tRPC procedure (the equivalent of a route hand
You define your procedures in `routers` which represent a collection of related procedures with a shared namespace. You may have one router for `users`, one for `posts` and another one for `messages`. These routers can then be merged into a single, centralized `appRouter`:

```ts
// server/routers/index.ts
// server/routers/_app.ts
const appRouter = t.router({
users: userRouter,
posts: postRouter,
Expand Down