From 8626ab6b844e6a5a449c9ed412cdc3ff76b6bb84 Mon Sep 17 00:00:00 2001 From: Christopher Ehrlich Date: Thu, 13 Oct 2022 17:50:57 +0200 Subject: [PATCH] feat: rename index.ts to _app.ts (#606) --- .changeset/loud-carrots-smash.md | 5 +++++ cli/src/installers/trpc.ts | 6 ++---- cli/template/addons/trpc/api-handler.ts | 2 +- cli/template/addons/trpc/{index-router.ts => app-router.ts} | 2 +- .../trpc/{auth-index-router.ts => auth-app-router.ts} | 2 +- cli/template/addons/trpc/utils.ts | 2 +- www/src/pages/en/usage/trpc.md | 2 +- 7 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 .changeset/loud-carrots-smash.md rename cli/template/addons/trpc/{index-router.ts => app-router.ts} (87%) rename cli/template/addons/trpc/{auth-index-router.ts => auth-app-router.ts} (88%) diff --git a/.changeset/loud-carrots-smash.md b/.changeset/loud-carrots-smash.md new file mode 100644 index 0000000000..8b6769b9bf --- /dev/null +++ b/.changeset/loud-carrots-smash.md @@ -0,0 +1,5 @@ +--- +"create-t3-app": minor +--- + +rename index.ts to \_app.ts diff --git a/cli/src/installers/trpc.ts b/cli/src/installers/trpc.ts index 6567400109..3fcbe8da07 100644 --- a/cli/src/installers/trpc.ts +++ b/cli/src/installers/trpc.ts @@ -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 diff --git a/cli/template/addons/trpc/api-handler.ts b/cli/template/addons/trpc/api-handler.ts index 8d800b8167..0d33fef5c8 100644 --- a/cli/template/addons/trpc/api-handler.ts +++ b/cli/template/addons/trpc/api-handler.ts @@ -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"; diff --git a/cli/template/addons/trpc/index-router.ts b/cli/template/addons/trpc/app-router.ts similarity index 87% rename from cli/template/addons/trpc/index-router.ts rename to cli/template/addons/trpc/app-router.ts index 8b28185428..71f4cbca72 100644 --- a/cli/template/addons/trpc/index-router.ts +++ b/cli/template/addons/trpc/app-router.ts @@ -1,4 +1,4 @@ -// src/server/router/index.ts +// src/server/router/_app.ts import { router } from "../trpc"; import { exampleRouter } from "./example"; diff --git a/cli/template/addons/trpc/auth-index-router.ts b/cli/template/addons/trpc/auth-app-router.ts similarity index 88% rename from cli/template/addons/trpc/auth-index-router.ts rename to cli/template/addons/trpc/auth-app-router.ts index 147ddd2b9b..7d12ca4f06 100644 --- a/cli/template/addons/trpc/auth-index-router.ts +++ b/cli/template/addons/trpc/auth-app-router.ts @@ -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"; diff --git a/cli/template/addons/trpc/utils.ts b/cli/template/addons/trpc/utils.ts index f79d2bd7e4..52a4f3072b 100644 --- a/cli/template/addons/trpc/utils.ts +++ b/cli/template/addons/trpc/utils.ts @@ -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 = () => { diff --git a/www/src/pages/en/usage/trpc.md b/www/src/pages/en/usage/trpc.md index e14a7f9455..13dbe5ec32 100644 --- a/www/src/pages/en/usage/trpc.md +++ b/www/src/pages/en/usage/trpc.md @@ -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,