refactor(web-next): move bindAll to root layout
Centralizes DI initialization in the root layout so individual pages and the tRPC route handler no longer need to import or call it.
This commit is contained in:
@@ -2,10 +2,8 @@ import { dehydrate, HydrationBoundary } from "@tanstack/react-query";
|
||||
import { appRouter } from "@repo/core-api";
|
||||
import { getQueryClient } from "@repo/core-trpc";
|
||||
import { PageContent } from "@repo/marketing-pages/ui";
|
||||
import { bindAll } from "../../server/bind-production";
|
||||
|
||||
export default async function AboutPage() {
|
||||
await bindAll();
|
||||
const caller = appRouter.createCaller({});
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
|
||||
import { appRouter } from "@repo/core-api";
|
||||
import { bindAll } from "../../../../server/bind-production";
|
||||
|
||||
const handler = async (req: Request) => {
|
||||
await bindAll();
|
||||
return fetchRequestHandler({
|
||||
endpoint: "/api/trpc",
|
||||
req,
|
||||
|
||||
@@ -3,14 +3,12 @@ import { dehydrate, HydrationBoundary } from "@tanstack/react-query";
|
||||
import { appRouter } from "@repo/core-api";
|
||||
import { getQueryClient } from "@repo/core-trpc";
|
||||
import { ArticleDetail } from "@repo/blog/ui";
|
||||
import { bindAll } from "../../../server/bind-production";
|
||||
|
||||
type PageProps = {
|
||||
params: Promise<{ slug: string }>;
|
||||
};
|
||||
|
||||
export default async function BlogPostPage({ params }: PageProps) {
|
||||
await bindAll();
|
||||
const { slug } = await params;
|
||||
const caller = appRouter.createCaller({});
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { Metadata } from "next";
|
||||
import "../styles/app.css";
|
||||
import { getNonce } from "@repo/core-shared/security/next";
|
||||
import { bindAll } from "../server/bind-production";
|
||||
import { Providers } from "./providers";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
@@ -13,6 +14,7 @@ export default async function RootLayout({
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
await bindAll();
|
||||
const nonce = await getNonce();
|
||||
|
||||
return (
|
||||
|
||||
@@ -3,10 +3,8 @@ import { appRouter } from "@repo/core-api";
|
||||
import { getQueryClient } from "@repo/core-trpc";
|
||||
import { SiteHeader } from "@repo/navigation/ui";
|
||||
import { ArticleList } from "@repo/blog/ui";
|
||||
import { bindAll } from "../server/bind-production";
|
||||
|
||||
export default async function Home() {
|
||||
await bindAll();
|
||||
const caller = appRouter.createCaller({});
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user