Skip to content

Commit a459fad

Browse files
authored
pack it up
pack it up purrito
2 parents d36f195 + 2d6c53a commit a459fad

File tree

27 files changed

+345
-352
lines changed

27 files changed

+345
-352
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
}
5252
},
5353
"dependencies": {
54+
"@tanstack/react-router": "^1.141.2",
5455
"autoprefixer": "^10.4.22",
5556
"chart.js": "^4.5.1",
5657
"postcss": "^8.5.6"

packages/api/src/client.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/api/src/index.ts

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,4 @@
1-
import { z } from 'zod';
2-
3-
import { createTRPCRouter, publicProcedure } from './trpc-server';
4-
5-
const portalRouter = createTRPCRouter({
6-
getDashboard: publicProcedure.query(() => ({
7-
title: 'Demo Dashboard',
8-
widgets: [],
9-
stats: {
10-
users: 1234,
11-
revenue: 9876,
12-
growth: 12,
13-
},
14-
})),
15-
16-
updateProfile: publicProcedure
17-
.input(z.object({ name: z.string(), email: z.string() }))
18-
.mutation(({ input }) => {
19-
// No-op mutation for demo purposes
20-
return { success: true, input };
21-
}),
22-
});
23-
24-
export const appRouter = createTRPCRouter({
25-
health: publicProcedure.query(() => ({ ok: true })),
26-
portal: portalRouter,
27-
});
28-
29-
export type AppRouter = typeof appRouter;
30-
31-
export default appRouter;
1+
// packages/api/src/index.ts
2+
export { appRouter, createContext } from './root';
3+
export type { AppRouter, Context } from './root';
4+
export { trpc, createTRPCRouter, publicProcedure } from './trpc';

packages/api/src/middleware.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/api/src/root.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { createTRPCRouter } from './trpc';
2+
import { helloRouter } from './routers/hello';
3+
4+
// Context type
5+
export type Context = {};
6+
7+
// Context creator
8+
export const createContext = async (): Promise<Context> => {
9+
return {};
10+
};
11+
12+
// Root app router
13+
export const appRouter = createTRPCRouter({
14+
hello: helloRouter,
15+
});
16+
17+
// Export API type
18+
export type AppRouter = typeof appRouter;

packages/api/src/routers/hello.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { createTRPCRouter, publicProcedure } from '../trpc';
2+
3+
export const helloRouter = createTRPCRouter()({
4+
sayHello: publicProcedure.query(() => {
5+
return { message: 'Hello, world!' };
6+
}),
7+
});

packages/api/src/trpc.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
import { createTRPCReact } from '@trpc/react-query';
2-
import type { AppRouter } from './index';
3-
import { httpBatchLink } from '@trpc/client';
1+
// packages/api/src/trpc.ts
2+
import { initTRPC } from '@trpc/server';
3+
import { Context } from './root';
44

5-
export const trpc = createTRPCReact<AppRouter>();
5+
export const t = initTRPC.context<Context>().create();
66

7-
export function createTrpcClient(baseUrl = '') {
8-
return trpc.createClient({
9-
links: [
10-
httpBatchLink({
11-
url: `${baseUrl || ''}/api/trpc`,
12-
}),
13-
],
14-
});
15-
}
7+
export const createTRPCRouter = t.router;
168

17-
export type Trpc = typeof trpc;
9+
export const publicProcedure = t.procedure;

packages/auth/src/hooks.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

pnpm-lock.yaml

Lines changed: 120 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)