feat(trpc): implement tRPC integration for accounts module

- Add tRPC server setup with NestJS (nestjs-trpc)
- Create AccountsTrpcRouter with CRUD operations
- Add tRPC client configuration in webapp
- Create tRPC React hooks for accounts module
- Replace existing REST hooks with tRPC hooks across 35+ files
- Maintain backward compatibility with existing REST API
- Add proper cache invalidation for mutations

New files:
- packages/server/src/modules/Trpc/*
- packages/webapp/src/trpc.ts
- packages/webapp/src/hooks/trpc/*
- shared/bigcapital-utils/src/trpc.ts

Dependencies added:
- @trpc/server, @trpc/client, @trpc/react-query
- nestjs-trpc, superjson
- @tanstack/react-query

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ahmed Bouhuolia
2026-02-24 04:34:04 +02:00
parent 688b1bfb56
commit 3bf2803360
48 changed files with 622 additions and 85 deletions

View File

@@ -1,3 +1,4 @@
export * from './countries';
export * from './trpc';
export const test = () => {};

View File

@@ -0,0 +1,32 @@
/**
* tRPC Router Types
* This file exports the types for the tRPC router that are shared between
* the server and the webapp (frontend).
*
* Note: This file only contains TYPE definitions. It does not import any
* runtime code from the server to avoid bundle bloat in the webapp.
*/
// We define the router type structure here to avoid importing the actual router
// from the server package, which would cause issues with bundling.
import type { inferRouterInputs, inferRouterOutputs } from '@trpc/server';
// This is a placeholder type that will be replaced by the actual router type
// when the server builds and exports it.
// The webapp will import the actual type from the server package during development
// but will use the built type declaration during production.
export type AppRouter = any;
/**
* Inference helpers for input types
* @example type MyInput = RouterInputs['accounts']['getAccount']
*/
export type RouterInputs = inferRouterInputs<AppRouter>;
/**
* Inference helpers for output types
* @example type MyOutput = RouterOutputs['accounts']['getAccount']
*/
export type RouterOutputs = inferRouterOutputs<AppRouter>;