-
-
Notifications
You must be signed in to change notification settings - Fork 128
feat(nest): module configuration #710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including You can disable this status message by setting the WalkthroughThis update introduces a configurable NestJS module ( Changes
Sequence Diagram(s)sequenceDiagram
participant AppModule
participant ORPCModule
participant ImplementInterceptor
participant onErrorInterceptor
participant ClientRequest
participant sendStandardResponse
AppModule->>ORPCModule: import ORPCModule.forRoot({ onError, eventIteratorKeepAliveInterval })
ORPCModule->>ImplementInterceptor: Inject config
ClientRequest->>ImplementInterceptor: intercept(request)
ImplementInterceptor->>onErrorInterceptor: handle error (if occurs)
ImplementInterceptor->>sendStandardResponse: send response with config
Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes found. Possibly related PRs
Suggested labels
Poem
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @unnoq, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request enhances the @orpc/nest module by adding configuration options through a new ORPCModule. This allows developers to configure interceptors and event iterator keep-alive intervals, providing more control over the behavior of oRPC services within NestJS applications. The changes include updates to documentation, build configurations, and testing to ensure the new module functions as expected.
Highlights
- Module Configuration: Introduces
ORPCModulefor configuring the@orpc/nestmodule in NestJS applications, allowing the use of interceptors and setting the event iterator keep-alive interval. - Interceptor Implementation: Implements
ImplementInterceptorto intercept requests and responses, using the configuration provided viaORPCModule. - Build Configuration: Updates build configurations to enable experimental decorators and adjust output settings.
- Testing: Adds a test case to verify the functionality of
ORPCModule.forRootwith interceptors.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces the ability to configure the @orpc/nest module using ORPCModule.forRoot(), enabling the setting of global interceptors and other options. The implementation adheres to NestJS patterns for dynamic modules, including documentation, tests, and a playground example. The review focuses on ensuring null safety when accessing the module configuration.
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
More templates
@orpc/arktype
@orpc/client
@orpc/contract
@orpc/experimental-durable-event-iterator
@orpc/hey-api
@orpc/nest
@orpc/openapi
@orpc/openapi-client
@orpc/react
@orpc/react-query
@orpc/server
@orpc/shared
@orpc/solid-query
@orpc/standard-server
@orpc/standard-server-aws-lambda
@orpc/standard-server-fetch
@orpc/standard-server-node
@orpc/standard-server-peer
@orpc/svelte-query
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/vue-colada
@orpc/vue-query
@orpc/zod
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
apps/content/docs/openapi/integrations/implement-contract-in-nest.md(1 hunks)packages/nest/build.config.ts(1 hunks)packages/nest/src/implement.test.ts(2 hunks)packages/nest/src/implement.ts(5 hunks)packages/nest/src/index.ts(1 hunks)packages/nest/src/module.ts(1 hunks)packages/nest/tsconfig.json(1 hunks)playgrounds/nest/build.config.ts(1 hunks)playgrounds/nest/package.json(2 hunks)playgrounds/nest/src/app.module.ts(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
playgrounds/nest/src/app.module.ts (2)
packages/nest/src/module.ts (1)
Module(15-31)packages/nest/src/index.ts (1)
onError(6-6)
🪛 GitHub Actions: CI
playgrounds/nest/package.json
[error] 1-1: pnpm install failed due to outdated lockfile. The pnpm-lock.yaml is not up to date with package.json. Dependencies added: unbuild@^3.5.0, removed: tsx@^4.20.3. Use 'pnpm install --no-frozen-lockfile' to bypass.
🪛 Biome (1.9.4)
packages/nest/src/module.ts
[error] 16-31: Avoid classes that contain only static members.
Prefer using simple functions instead of classes with only static members.
(lint/complexity/noStaticOnlyClass)
🔇 Additional comments (15)
packages/nest/tsconfig.json (1)
4-4: LGTM! Essential TypeScript configuration for NestJS decorators.The addition of
emitDecoratorMetadata: trueis necessary for NestJS's dependency injection system to work properly with decorators and metadata reflection.packages/nest/build.config.ts (1)
1-13: Well-structured build configuration for decorator support.The unbuild configuration correctly enables experimental decorators support, which aligns with the TypeScript configuration changes and is essential for building the NestJS integration.
playgrounds/nest/package.json (1)
6-6: Script update aligns with new build configuration.The change from tsx to unbuild with the
.mjsextension is consistent with the new build configuration using unbuild.playgrounds/nest/src/app.module.ts (1)
8-8: Import statement looks good.The imports correctly bring in the necessary exports from the nest package.
packages/nest/src/index.ts (2)
3-3: Essential export for module functionality.Adding the module export makes the ORPCModule and related types available for external use, which is necessary for the NestJS integration.
6-6: Comprehensive lifecycle event handler exports.The addition of onError, onFinish, onStart, and onSuccess exports provides users with all necessary lifecycle hooks for configuring interceptors, as demonstrated in the playground usage.
playgrounds/nest/build.config.ts (1)
1-18: LGTM! Clean build configuration for the playground.The unbuild configuration is well-structured and correctly enables TypeScript experimental decorators support, which aligns with the NestJS decorators used in the module implementation.
apps/content/docs/openapi/integrations/implement-contract-in-nest.md (1)
223-250: Excellent documentation addition!The new Configuration section provides clear guidance on module setup with practical examples. The explanatory notes about interceptors and event iterator keep-alive are particularly helpful for users.
packages/nest/src/implement.test.ts (2)
7-14: Good addition of test infrastructure.The spy on
sendStandardResponseand the import ofStandardServerNodeprovide the necessary testing infrastructure for verifying module configuration integration.
384-414: Comprehensive test coverage for module integration.The test effectively verifies that:
- The module configuration is properly injected and used
- HTTP behavior remains unchanged
- Interceptors are called correctly
- Configuration options are passed to
sendStandardResponseThis ensures the module integration works as expected.
packages/nest/src/implement.ts (3)
11-12: Proper imports for module integration.The addition of
ORPCModuleConfigtype andORPC_MODULE_CONFIG_SYMBOLimports correctly supports the dependency injection pattern.Also applies to: 22-22
102-107: Excellent dependency injection implementation.The
@Injectable()decorator and constructor properly implement NestJS dependency injection patterns. Using@Optional()for the config ensures the interceptor works both with and without module configuration.
135-135: Correct configuration integration.The injected configuration is properly passed to both
createProcedureClientandsendStandardResponse, enabling module-level configuration to affect procedure behavior and response handling.Also applies to: 160-160
packages/nest/src/module.ts (2)
8-13: Well-designed configuration interface and symbol.The
ORPC_MODULE_CONFIG_SYMBOLprovides proper type safety for dependency injection, andORPCModuleConfigcorrectly extends the necessary option interfaces for comprehensive configuration support.
15-31: Proper NestJS dynamic module implementation.The
forRootmethod follows NestJS conventions perfectly:
- Returns a proper dynamic module configuration
- Registers configuration and interceptor as providers
- Exports necessary providers for dependency injection
global: trueis appropriate for this type of infrastructure moduleThe static analysis hint about avoiding static-only classes is a false positive here - this is the standard and expected pattern for NestJS dynamic modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a configurable ORPCModule for NestJS, allowing centralized setup of lifecycle interceptors and event-stream keep-alive intervals, and updates related build and playground configurations.
- Add
ORPCModule.forRoot(...)to playground to demonstrate module configuration. - Implement
ORPCModuleConfiginjection in the interceptor and wire it throughcreateProcedureClientandsendStandardResponse. - Update build scripts (
unbuild), TypeScript configs, exports, and add a test verifying the new module API.
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| playgrounds/nest/src/app.module.ts | Import and configure ORPCModule.forRoot with error interceptor and keep-alive interval |
| playgrounds/nest/package.json | Update preview script to use unbuild and node dist/main.mjs; remove tsx dependency |
| playgrounds/nest/build.config.ts | Add Unbuild configuration for experimental decorators |
| packages/nest/tsconfig.json | Enable emitDecoratorMetadata to support decorator metadata |
| packages/nest/src/module.ts | Define ORPCModule, symbol, and config interface |
| packages/nest/src/index.ts | Export the new module and re-export additional lifecycle hooks |
| packages/nest/src/implement.ts | Inject ORPCModuleConfig into ImplementInterceptor and pass it to client and response functions |
| packages/nest/src/implement.test.ts | Add test for ORPCModule.forRoot, spying on sendStandardResponse |
| packages/nest/build.config.ts | Add Unbuild configuration for the Nest package |
| apps/content/docs/.../implement-contract-in-nest.md | Document ORPCModule.forRoot usage and config options |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (2)
packages/nest/src/implement.ts:12
- The interceptor class uses NestInterceptor, ExecutionContext, and CallHandler types but they aren't imported. Please add
NestInterceptor,ExecutionContext, andCallHandlerto the import from '@nestjs/common'.
import { applyDecorators, Delete, Get, Head, Inject, Injectable, Optional, Patch, Post, Put, UseInterceptors } from '@nestjs/common'
packages/nest/src/implement.test.ts:390
- The test uses
eventIteratorKeepAliveComment, but the module API expectseventIteratorKeepAliveInterval. Rename this property to match the actual config option.
eventIteratorKeepAliveComment: '__TEST__',
Closes: https://github.com/unnoq/orpc/issues/709
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Chores