Skip to content

Commit 290ca07

Browse files
authored
Merge pull request #41 from GRACENOBLE/trpc
feat(web): set up tRPC v11 API layer with React Query v5
2 parents b471f47 + 2fa6b59 commit 290ca07

28 files changed

Lines changed: 901 additions & 65 deletions

‎backend/docker-compose.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
psql_bp:
3-
image: postgres:latest
3+
image: postgres:16
44
restart: unless-stopped
55
environment:
66
POSTGRES_DB: ${BLUEPRINT_DB_DATABASE}

‎backend/internal/infrastructure/database/postgres/health_repository_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func mustStartPostgresContainer() (func(context.Context, ...testcontainers.Termi
2323

2424
container, err := tcpostgres.Run(
2525
context.Background(),
26-
"postgres:latest",
26+
"postgres:16",
2727
tcpostgres.WithDatabase(dbName),
2828
tcpostgres.WithUsername(dbUser),
2929
tcpostgres.WithPassword(dbPwd),

‎web/AGENTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Read the relevant doc before implementing. These are kept in sync with the code
5656
|---|---|
5757
| App Router, route files, layouts, navigation | [`docs/routing.md`](docs/routing.md) |
5858
| Server Components, data fetching, Server Actions | [`docs/data-fetching.md`](docs/data-fetching.md) |
59+
| tRPC routers, React Query, client/server usage | [`docs/trpc.md`](docs/trpc.md) |
5960
| Tailwind CSS v4, theme tokens, dark mode | [`docs/styling.md`](docs/styling.md) |
6061
| Component conventions, TypeScript rules | [`docs/components.md`](docs/components.md) |
6162
| Testing setup, patterns, what to test | [`docs/testing.md`](docs/testing.md) |

‎web/app/api/trpc/[trpc]/route.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { fetchRequestHandler } from '@trpc/server/adapters/fetch'
2+
import { type NextRequest } from 'next/server'
3+
import { createTRPCContext } from '@/server/trpc'
4+
import { appRouter } from '@/server/routers/_app'
5+
6+
const handler = (req: NextRequest) =>
7+
fetchRequestHandler({
8+
endpoint: '/api/trpc',
9+
req,
10+
router: appRouter,
11+
createContext: () => createTRPCContext({ req }),
12+
})
13+
14+
export { handler as GET, handler as POST }

‎web/app/layout.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Metadata } from "next";
22
import { Geist, Geist_Mono } from "next/font/google";
33
import "./globals.css";
4+
import { Providers } from "./providers";
45

56
const geistSans = Geist({
67
variable: "--font-geist-sans",
@@ -27,7 +28,9 @@ export default function RootLayout({
2728
lang="en"
2829
className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}
2930
>
30-
<body className="min-h-full flex flex-col">{children}</body>
31+
<body className="min-h-full flex flex-col">
32+
<Providers>{children}</Providers>
33+
</body>
3134
</html>
3235
);
3336
}

‎web/app/page.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
import About from "@/components/home/about";
2+
import Hero from "@/components/home/hero";
3+
14
const page = () => {
25
return (
3-
<div></div>
6+
<div>
7+
<Hero />
8+
<About />
9+
</div>
410
);
511
};
612

7-
export default page;
13+
export default page;

‎web/app/providers.tsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use client'
2+
3+
import { TRPCProvider } from '@/lib/trpc/client'
4+
5+
export function Providers({ children }: { children: React.ReactNode }) {
6+
return <TRPCProvider>{children}</TRPCProvider>
7+
}

‎web/components/home/about.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const About = () => {
2+
return <section></section>;
3+
};
4+
5+
export default About;

‎web/components/home/hero.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const Hero = () => {
2+
return <section></section>;
3+
};
4+
5+
export default Hero;

‎web/docs/_index.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ The `docs` agent reads this index first to locate the right file.
66
| Topic | File | Source files covered |
77
|---|---|---|
88
| App Router structure & route conventions | [routing.md](routing.md) | `app/layout.tsx`, `app/page.tsx`, `next.config.ts` |
9-
| Data fetching patterns | [data-fetching.md](data-fetching.md) | `app/page.tsx`, `app/layout.tsx` |
9+
| Data fetching patterns | [data-fetching.md](data-fetching.md) | `app/page.tsx`, `app/layout.tsx`, `lib/trpc/server.ts`, `lib/trpc/client.tsx` |
10+
| tRPC v11 + React Query v5 — routers, context, client/server usage | [trpc.md](trpc.md) | `server/trpc.ts`, `server/routers/_app.ts`, `lib/trpc/client.tsx`, `lib/trpc/server.ts`, `app/providers.tsx` |
1011
| Styling with Tailwind CSS v4 | [styling.md](styling.md) | `app/globals.css`, `postcss.config.mjs` |
1112
| Component conventions | [components.md](components.md) | `app/` (all component files) |
1213
| Testing patterns | [testing.md](testing.md) | `vitest.config.ts`, `vitest.setup.ts`, `__tests__/page.test.tsx` |

0 commit comments

Comments
 (0)