feat(API): Migrate to oRPC with automatic OpenAPI generation for internal and public APIs #54
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates both internal and public APIs from tRPC/manual REST to oRPC, leveraging automatic OpenAPI generation for improved developer experience and type safety, it's also more portable and better performant.
Changes
enhanced development env docs + 3rd parties lazy required for faster development startup.
decoupled business logic from router, layer-system.
Internal API Migration
useORPC) instead of tRPC/api/(internal-api)/orpc/[...orpc]/route.ts/api/orpc/openapi.json@orpc/client,@orpc/server,@orpc/react-query,@orpc/openapi,@orpc/zodTRPCReactProvidertoORPCReactProviderPublic API Refactoring
OpenAPIHandler/api/(public-api)/v1/namespace/(documents, ingest-jobs, hosting, uploads, etc.)/api/(public-api)/v1/[...path]/route.tsusing oRPC'sOpenAPIHandler/api/(public-api)/v1/openapi.jsonzod-openapiand all files insrc/openapi/directory)OpenAPI Generation
@orpc/openapifor both internal and public APIs/api/orpc/openapi.json/api/(public-api)/v1/openapi.jsonInfrastructure Improvements
Technical Details
Internal API Structure
@orpc/react-queryPublic API Structure
OpenAPIHandlerMigration Notes
Internal API consumers: Updated to use oRPC hooks - breaking change from tRPC
Public API consumers: API endpoints remain the same, but now powered by oRPC with automatic OpenAPI generation
OpenAPI specs: Now automatically generated instead of manually maintained
OpenAPI endpoints:
/api/orpc/openapi.json/api/(public-api)/v1/openapi.jsonAll internal API routes migrated to oRPC
All client components updated to use oRPC hooks
Public API endpoints working with oRPC handler
OpenAPI specifications generating correctly for both APIs