Skip to content

feat(nestjs): add nestjs middleware support (#21) #98

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

Merged
merged 4 commits into from
Apr 19, 2025

Conversation

Groupguanfang
Copy link
Owner

No description provided.

@Copilot Copilot AI review requested due to automatic review settings April 19, 2025 09:42
@Groupguanfang Groupguanfang changed the title feat(nestjs): add middleware support (#21) feat(nestjs): add nestjs middleware support (#21) Apr 19, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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 adds middleware support for the NestJS adapter by integrating middleware resolution and execution logic into the RESTful scanning and handling processes.

  • Introduces middleware resolution (resolveMiddlewares) and execution (executeMiddlewares) in the NestJSRestfulScanner class.
  • Updates the NestJSRestfulHandler to execute middlewares before processing parameters and guards.
  • Refactors middleware configuration and the related builders (MiddlewareCustomerBuilder and MiddlewareConfigProxyBuilder) and enhances module resolution checks.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/adapter/adapter-nestjs/src/restful/restful-scanner.ts Implements middleware resolution and execution via new methods.
packages/adapter/adapter-nestjs/src/restful/restful-handler.ts Adjusts handler logic to execute middlewares prior to other actions.
packages/adapter/adapter-nestjs/src/plugin.ts Instantiates the scanner with resolved modules, removing legacy code.
packages/adapter/adapter-nestjs/src/nest-resolver.ts Adds an isResolved flag and throws errors if resolution is missing.
packages/adapter/adapter-nestjs/src/middleware/middleware-customer.ts Refactors middleware consumer to a builder with an updated map.
packages/adapter/adapter-nestjs/src/middleware/middleware-config-proxy.ts Updates route configuration methods in middleware proxy.
.changeset/53c35bd6c1dad04be84922fce98d039b81c5b5b7.md Minor changeset noting version bump for middleware support.

handler: instance.use,
instance,
routes: this._routes,
for (const route of routes) {
Copy link
Preview

Copilot AI Apr 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The forRoutes method is adding routes to the excludedRoutes array instead of the intended includedRoutes. This likely causes middleware inclusion logic to fail; please update it to push routes into includedRoutes.

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

@Groupguanfang Groupguanfang merged commit 4610716 into v1 Apr 19, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants