-
-
Notifications
You must be signed in to change notification settings - Fork 291
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
Refactor platform multer #3003
base: production
Are you sure you want to change the base?
Refactor platform multer #3003
Conversation
…ter decorators declared in platform-http
WalkthroughThese changes refactor the multipart and middleware handling across the platform packages. Custom implementations of multer functionality in Express, HTTP, and Koa are removed in favor of re-exporting and integrating the external package Changes
Sequence Diagram(s)sequenceDiagram
participant EP as Endpoint Request
participant PH as PlatformHandler
participant PAME as PlatformAcceptMimesMiddleware
EP->>PH: Incoming request
PH->>PAME: Call $alterEndpointHandlers(handlers, operationRoute)
Note right of PAME: Check for acceptMimes in endpoint & middleware property
PAME-->>PH: Return updated handlers with middleware added (if condition met)
PH->>EP: Process request using modified handlers
sequenceDiagram
participant Adapter as PlatformAdapter
participant MulterMod as MULTER_MODULE (Injected)
Adapter->>MulterMod: Call get(options)
MulterMod-->>Adapter: Return multer middleware instance
✨ Finishing Touches
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:
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.
Actionable comments posted: 21
🔭 Outside diff range comments (2)
packages/platform/platform-multer/vitest.config.mts (1)
1-22
: 🧹 Nitpick (assertive)New Vitest Configuration File
This new configuration file correctly extends presets from@tsed/vitest/presets
and properly sets the coverage thresholds.
- Note: The presence of the
// @ts-ignore
comment on line 1 hints at a type issue. It would be beneficial to document why this ignore is necessary or investigate a permanent fix if possible.packages/platform/platform-http/src/common/decorators/multer/multipartFile.ts (1)
5-50
: 🧹 Nitpick (assertive)Update JSDoc to reflect implementation changes.
The JSDoc comment doesn't reflect that the implementation has been moved to
@tsed/platform-multer
. It still describes the functionality as if it were implemented in this file. Consider updating the JSDoc to mention that this is now a re-export from the new package./** * Define a parameter as Multipart file. +* +* This is a re-export from @tsed/platform-multer package. * ...
♻️ Duplicate comments (1)
packages/platform/platform-http/src/common/decorators/multer/multerFileSize.ts (1)
1-1
:⚠️ Potential issueMissing dependency for
@tsed/platform-multer
Similar to other files, the code imports from
@tsed/platform-multer
, but this module cannot be found. This causes build failures in various test suites.🧰 Tools
🪛 GitHub Check: test-core (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-third-parties (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-security (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-platform (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-graphql (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-orm (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-specs (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
yarn.lock
is excluded by!**/yarn.lock
,!**/*.lock
📒 Files selected for processing (43)
docs/docs/snippets/middlewares/platform-accept-mimes-middleware.ts
(2 hunks)packages/platform/platform-express/src/components/PlatformExpress.ts
(1 hunks)packages/platform/platform-http/package.json
(1 hunks)packages/platform/platform-http/src/common/config/interfaces/PlatformMulterSettings.ts
(1 hunks)packages/platform/platform-http/src/common/decorators/multer/multerFileSize.ts
(2 hunks)packages/platform/platform-http/src/common/decorators/multer/multerOptions.ts
(2 hunks)packages/platform/platform-http/src/common/decorators/multer/multipartFile.ts
(2 hunks)packages/platform/platform-http/src/common/index.ts
(0 hunks)packages/platform/platform-http/src/common/middlewares/PlatformAcceptMimesMiddleware.ts
(1 hunks)packages/platform/platform-http/src/common/middlewares/PlatformMulterMiddleware.ts
(1 hunks)packages/platform/platform-http/src/common/services/PlatformAdapter.ts
(2 hunks)packages/platform/platform-http/src/common/services/PlatformApplication.ts
(1 hunks)packages/platform/platform-http/src/common/services/PlatformHandler.ts
(2 hunks)packages/platform/platform-http/src/common/services/PlatformMiddlewaresChain.spec.ts
(0 hunks)packages/platform/platform-http/src/common/services/PlatformMiddlewaresChain.ts
(0 hunks)packages/platform/platform-http/tsconfig.json
(1 hunks)packages/platform/platform-http/tsconfig.spec.json
(1 hunks)packages/platform/platform-koa/package.json
(1 hunks)packages/platform/platform-koa/src/components/PlatformKoa.ts
(1 hunks)packages/platform/platform-koa/src/index.ts
(0 hunks)packages/platform/platform-multer/.barrelsby.json
(1 hunks)packages/platform/platform-multer/package.json
(1 hunks)packages/platform/platform-multer/src/adapters/express/MulterModule.ts
(1 hunks)packages/platform/platform-multer/src/adapters/koa/MulterModule.ts
(2 hunks)packages/platform/platform-multer/src/common/constants/constants.ts
(1 hunks)packages/platform/platform-multer/src/common/decorators/multerFileSize.spec.ts
(2 hunks)packages/platform/platform-multer/src/common/decorators/multerFileSize.ts
(1 hunks)packages/platform/platform-multer/src/common/decorators/multerOptions.spec.ts
(2 hunks)packages/platform/platform-multer/src/common/decorators/multerOptions.ts
(1 hunks)packages/platform/platform-multer/src/common/decorators/multipartFile.spec.ts
(4 hunks)packages/platform/platform-multer/src/common/decorators/multipartFile.ts
(1 hunks)packages/platform/platform-multer/src/common/errors/MulterException.ts
(1 hunks)packages/platform/platform-multer/src/common/index.ts
(1 hunks)packages/platform/platform-multer/src/common/interfaces/PlatformMulterSettings.ts
(1 hunks)packages/platform/platform-multer/src/common/middlewares/PlatformMulterMiddleware.spec.ts
(4 hunks)packages/platform/platform-multer/src/common/middlewares/PlatformMulterMiddleware.ts
(1 hunks)packages/platform/platform-multer/src/index.ts
(1 hunks)packages/platform/platform-multer/tsconfig.esm.json
(1 hunks)packages/platform/platform-multer/tsconfig.json
(1 hunks)packages/platform/platform-multer/tsconfig.spec.json
(1 hunks)packages/platform/platform-multer/vitest.config.mts
(1 hunks)tools/vitest/presets/index.js
(1 hunks)tsconfig.json
(1 hunks)
💤 Files with no reviewable changes (4)
- packages/platform/platform-http/src/common/index.ts
- packages/platform/platform-koa/src/index.ts
- packages/platform/platform-http/src/common/services/PlatformMiddlewaresChain.ts
- packages/platform/platform-http/src/common/services/PlatformMiddlewaresChain.spec.ts
🧰 Additional context used
🧠 Learnings (1)
packages/platform/platform-multer/tsconfig.json (1)
Learnt from: Romakita
PR: tsedio/tsed#2925
File: packages/platform/platform-fastify/tsconfig.esm.json:3-11
Timestamp: 2024-12-10T17:46:27.733Z
Learning: Dans le projet Ts.ED, lorsqu'un fichier `tsconfig` comme `packages/platform/platform-fastify/tsconfig.esm.json` étend `"@tsed/typescript/tsconfig.node.json"`, il n'est pas nécessaire de répéter les options du compilateur telles que `"moduleResolution": "node"` et `"sourceMap": true`, car elles sont déjà incluses dans le fichier de configuration étendu.
🪛 Biome (1.9.4)
packages/platform/platform-http/src/common/services/PlatformHandler.ts
[error] 35-35: Reassigning a function parameter is confusing.
The parameter is declared here:
Use a local variable instead.
(lint/style/noParameterAssign)
packages/platform/platform-multer/src/common/decorators/multipartFile.ts
[error] 72-72: Forbidden non-null assertion.
(lint/style/noNonNullAssertion)
[error] 72-72: Reassigning a function parameter is confusing.
The parameter is declared here:
Use a local variable instead.
(lint/style/noParameterAssign)
packages/platform/platform-multer/src/common/middlewares/PlatformMulterMiddleware.ts
[error] 28-28: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
🪛 GitHub Check: test-core (20.12.2)
packages/platform/platform-http/src/common/middlewares/PlatformMulterMiddleware.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/config/interfaces/PlatformMulterSettings.ts
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multerOptions.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multipartFile.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/services/PlatformAdapter.ts
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multerFileSize.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
🪛 GitHub Check: test-third-parties (20.12.2)
packages/platform/platform-http/src/common/middlewares/PlatformMulterMiddleware.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/config/interfaces/PlatformMulterSettings.ts
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multerOptions.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multipartFile.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/services/PlatformAdapter.ts
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multerFileSize.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
🪛 GitHub Check: test-security (20.12.2)
packages/platform/platform-http/src/common/middlewares/PlatformMulterMiddleware.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/config/interfaces/PlatformMulterSettings.ts
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multerOptions.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multipartFile.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/services/PlatformAdapter.ts
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multerFileSize.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
🪛 GitHub Check: test-platform (20.12.2)
packages/platform/platform-http/src/common/middlewares/PlatformMulterMiddleware.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/config/interfaces/PlatformMulterSettings.ts
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multerOptions.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multipartFile.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/services/PlatformAdapter.ts
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multerFileSize.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
🪛 GitHub Check: test-graphql (20.12.2)
packages/platform/platform-http/src/common/middlewares/PlatformMulterMiddleware.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/config/interfaces/PlatformMulterSettings.ts
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multerOptions.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multipartFile.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/services/PlatformAdapter.ts
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multerFileSize.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
🪛 GitHub Check: test-orm (20.12.2)
packages/platform/platform-http/src/common/middlewares/PlatformMulterMiddleware.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/config/interfaces/PlatformMulterSettings.ts
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multerOptions.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multipartFile.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/services/PlatformAdapter.ts
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multerFileSize.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
🪛 GitHub Check: test-specs (20.12.2)
packages/platform/platform-http/src/common/middlewares/PlatformMulterMiddleware.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/config/interfaces/PlatformMulterSettings.ts
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multerOptions.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multipartFile.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/services/PlatformAdapter.ts
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-http/src/common/decorators/multer/multerFileSize.ts
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
🪛 GitHub Actions: Build & Release
packages/platform/platform-http/src/common/services/PlatformAdapter.ts
[error] 6-6: error TS2307: Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: CodeQL-Build
🔇 Additional comments (64)
packages/platform/platform-multer/tsconfig.json (1)
1-35
: New TypeScript Configuration File for platform-multerThis configuration file properly extends
@tsed/typescript/tsconfig.node.json
and sets custom compiler options such as"baseUrl": "."
and"noEmit": true
. The"references"
array correctly points to the other core modules, supporting a modular architecture. Verify that an empty"include": []
is intentional, as it might be used solely for build or type checking purposes rather than for compiling source files.packages/platform/platform-multer/src/index.ts (1)
1-2
: Barrel Export ImplementationThe export statement uses the barrel pattern to re-export all entities from
"./common/index.js"
. This design simplifies module imports elsewhere in the project. Ensure that the.js
extension is intentional and aligns with your build output and module resolution strategy for TypeScript.packages/platform/platform-http/tsconfig.spec.json (1)
21-23
: New Path Mapping for @tsed/platform-multerThe newly added path mapping for
@tsed/platform-multer
that resolves to["../platform-multer/src/index.ts"]
is consistent with the project structure. This update ensures that tests and other parts of the codebase correctly resolve imports from the new multer package.tsconfig.json (1)
86-88
: New Reference in Global tsconfigAdding the reference to
"./packages/platform/platform-multer/tsconfig.json"
aligns the global TypeScript configuration with the new package structure. This inclusion ensures that the platform-multer package is properly integrated into the overall build and type checking processes.packages/platform/platform-http/package.json (1)
86-86
: Dependency Addition: Valid Inclusion of@tsed/platform-multer
The addition of"@tsed/platform-multer": "workspace:*"
aligns with the pull request objectives of modularizing multer functionality. Ensure that the workspace version is kept in sync with other related packages.packages/platform/platform-koa/package.json (1)
22-22
: Script Update: Test Command Modification
Changing the test command from"vitest run -u"
to"vitest run"
removes the automatic snapshot updating. Verify that this adjustment meets your team's testing workflow requirements.packages/platform/platform-multer/.barrelsby.json (1)
1-5
: Barrelsby Configuration Established
The new.barrelsby.json
file is well-configured to generate barrel files from the./src/common
directory, with appropriate exclusions for mocks, fixtures, and test files. The"delete": true
option is a good practice for removing outdated barrel files.packages/platform/platform-http/tsconfig.json (1)
33-35
: Enhancement: Adding a Project Reference forplatform-multer
The inclusion of the reference to"../platform-multer/tsconfig.json"
promotes modularity and ensures that TypeScript correctly recognizes the types and configurations from the new multer package. This is an effective enhancement to the overall project structure.packages/platform/platform-multer/src/common/errors/MulterException.ts (1)
1-10
: Well-structured error handling class.This is a good implementation of a custom exception class for handling Multer errors. The class properly extends the
BadRequest
exception and provides appropriate error handling. Setting thename
property to the error code is a good practice for error identification and debugging.packages/platform/platform-multer/src/common/decorators/multerOptions.ts (3)
1-4
: Appropriate import setup for the decorator.The imports are correctly set up, bringing in the necessary
StoreMerge
utility from@tsed/core
, theOptions
type frommulter
, and the local constantPLATFORM_MULTER_OPTIONS
.
6-46
: Excellent documentation with comprehensive examples.The JSDoc comments are well-written and include detailed usage examples, which is a best practice for decorator functions. The documentation clearly shows how to use the decorator in different scenarios and links to additional documentation.
47-53
: Clean and effective decorator implementation.The decorator function is well-implemented, using
StoreMerge
to store the options under the appropriate key. The code is concise and follows best practices for TypeScript decorators.packages/platform/platform-multer/src/common/decorators/multerFileSize.spec.ts (2)
3-3
: Import updated to use the new constant.The import has been correctly updated to use
PLATFORM_MULTER_OPTIONS
from the constants file, aligning with the refactoring effort to move away from the middleware approach.
14-14
: Test expectation updated to match new implementation.The test expectation has been correctly updated to check for the options stored under the
PLATFORM_MULTER_OPTIONS
key instead of the previous middleware approach.packages/platform/platform-multer/src/common/decorators/multerOptions.spec.ts (2)
3-3
: Import updated for consistency with refactoring.The import has been correctly updated to use
PLATFORM_MULTER_OPTIONS
from the constants file, which is consistent with the changes in other test files and the overall refactoring goal.
15-15
: Test expectation properly aligned with the new implementation.The test now correctly verifies that options are stored under the
PLATFORM_MULTER_OPTIONS
key, which matches the implementation in the decorator. This ensures that the test accurately validates the decorator's behavior.packages/platform/platform-multer/src/common/middlewares/PlatformMulterMiddleware.ts (2)
46-46
: LGTM: Appropriate use of dependency injection and priority settingThe use of the
injectable
decorator with appropriate type and priority is well-implemented.
1-46
:❓ Verification inconclusive
Questionable implementation: The entire file is being added only to be deprecated later
This file appears to define a complete
PlatformMulterMiddleware
class implementation, but the AI summary indicates that this class is being removed in favor of re-exporting from@tsed/platform-multer
. There seems to be a disconnect between this implementation and the intended refactoring.If the intention is to ultimately use a component from another package, this implementation seems unnecessary. The implementation should either be moved to the target package or simply re-exported directly.
🏁 Script executed:
#!/bin/bash # Look for imports of PlatformMulterMiddleware to understand usage patterns rg -A 3 "import.*PlatformMulterMiddleware" --glob "*.ts" # Look for any re-exports from @tsed/platform-multer rg -A 3 "export.*from.*@tsed/platform-multer" --glob "*.ts"Length of output: 1599
Action Required: Clarify Deprecation Strategy for PlatformMulterMiddleware Implementation
The current file provides a full implementation of PlatformMulterMiddleware even though there is an indication (e.g. in the platform-http package comment) that a re-export from @tsed/platform-multer is preferred. Our repository search confirms that:
- The implementation in this file is actively used within the platform-multer package (e.g. in decorators and tests).
- Other parts of the codebase (such as in the platform-http module) already import a re-export from @tsed/platform-multer with a deprecation notice in favor of a different package.
It’s unclear whether the intention is to immediately deprecate this complete implementation across all consumers, or if a transitional phase exists. Please confirm if we should proceed with a refactoring that:
- Updates all consumers to use a re-export from @tsed/platform-multer (or the new @tsed/platform-middlewares package), and
- Removes the current implementation from this file.
Once the overall deprecation strategy is clarified, we can adjust the implementation accordingly.
🧰 Tools
🪛 Biome (1.9.4)
[error] 28-28: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
packages/platform/platform-multer/src/common/constants/constants.ts (2)
3-7
: LGTM: Well-defined interface with clear type specificationsThe
MULTER_MODULE
interface correctly defines the structure needed for the Multer module integration, with appropriate typing for themulter
property and theget
method.
9-10
: LGTM: Good use of Symbol.for to ensure uniqueness and consistencyUsing
Symbol.for
is appropriate for creating unique identifiers that can be shared across modules without risk of collision.packages/platform/platform-multer/src/common/decorators/multerFileSize.ts (2)
3-29
: LGTM: Well-documented decorator with clear examplesThe documentation for the
MulterFileSize
decorator is excellent. It includes:
- A clear description of what the decorator does
- A complete, practical example of how to use it
- References to additional documentation
- JSDoc parameter and return type information
- Appropriate decorator tags
This level of documentation is very helpful for developers using the library.
30-32
: LGTM: Simple and effective implementationThe implementation is clean and concise, correctly using the
MulterOptions
decorator to apply file size limits.packages/platform/platform-multer/src/adapters/express/MulterModule.ts (2)
8-38
: LGTM: Well-structured async factory with promise adaptationThe factory function is well-designed:
- It dynamically imports multer to avoid loading it until needed
- It returns an object with the multer instance and a get method
- It wraps the multer methods to work with promises, which is excellent for async/await patterns
The implementation follows good practices for modernizing callback-based APIs to work with promises.
40-40
: LGTM: Appropriate dependency injection setupThe use of
injectable
withasyncFactory
andtoken
is a good approach for registering this factory function in the dependency injection system.packages/platform/platform-http/src/common/decorators/multer/multerOptions.ts (2)
45-45
: LGTM: Good use of re-export pattern for deprecation.The re-export approach provides a smooth transition path for users while maintaining backward compatibility.
1-1
:✅ Verification successful
Verify module resolution for @tsed/platform-multer.
The static analysis tools indicate that the module
@tsed/platform-multer
cannot be found. This suggests there might be issues with the package's setup or reference configuration.
🏁 Script executed:
#!/bin/bash # Check if @tsed/platform-multer is properly configured in workspace # Verify if package is included in the workspace echo "Checking workspace configuration..." grep -r "@tsed/platform-multer" package.json # Check the actual directory structure echo "Checking directory existence..." [ -d "packages/platform/platform-multer" ] && echo "Directory exists" || echo "Directory not found" # Check for any tsconfig path mappings echo "Checking for tsconfig path mappings..." grep -r "@tsed/platform-multer" tsconfig*.jsonLength of output: 442
I'll run an additional script to verify that the package located at
packages/platform/platform-multer/package.json
actually declares its name as"@tsed/platform-multer"
. This check will confirm whether the module is itself configured correctly even if the main workspace package.json and tsconfig files don’t explicitly reference it.Once you confirm that the output is
"@tsed/platform-multer"
, you can safely conclude that the module exists and is properly named. If the field is missing or different, then updating thepackage.json
in that directory would be needed.
Module Resolution Check for @tsed/platform-multer
- The folder
packages/platform/platform-multer
exists, which indicates that the module should be available in the monorepo.- Please verify that its
package.json
includes"name": "@tsed/platform-multer"
. If it does, the static analysis issue may be a false positive or a tooling configuration matter (e.g., missing path mappings in tsconfig).- If the package name is incorrect or absent, update the configuration accordingly.
🏁 Script executed:
#!/bin/bash echo "Verifying the package name in packages/platform/platform-multer/package.json:" jq '.name' packages/platform/platform-multer/package.json || echo "Unable to read package name or file not found."Length of output: 246
Module resolution for @tsed/platform-multer verified
After reviewing the workspace and checking the package configuration, we confirmed that the package located at
packages/platform/platform-multer
is correctly defined with"name": "@tsed/platform-multer"
in itspackage.json
. This suggests that the static analysis warning is likely a false positive or an issue with your tooling configuration (e.g., TypeScript path mappings). Please double-check your TS configuration if further resolution issues arise.🧰 Tools
🪛 GitHub Check: test-core (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-third-parties (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-security (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-platform (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-graphql (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-orm (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-specs (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.tools/vitest/presets/index.js (1)
10-11
: Properly configured module resolution aliases.The aliases for Express and Koa adapter-specific imports have been correctly set up, which will ensure that framework-specific multer implementations are properly loaded during testing.
packages/platform/platform-http/src/common/middlewares/PlatformMulterMiddleware.ts (2)
6-6
: LGTM: Good use of re-export pattern for deprecation.The re-export approach maintains backward compatibility while providing a clear migration path.
1-1
:❓ Verification inconclusive
Verify module resolution for @tsed/platform-multer.
The static analysis tools indicate that the module
@tsed/platform-multer
cannot be found. This suggests there might be issues with the package's setup or reference configuration.
🏁 Script executed:
#!/bin/bash # Check if the @tsed/platform-multer package is properly referenced in dependencies # Check if it's listed as a dependency in platform-http package.json echo "Checking dependencies in platform-http package.json..." grep -A 10 "dependencies" packages/platform/platform-http/package.json | grep -A 10 "@tsed/platform-multer" # Verify if it's included in the main package.json workspace echo "Checking workspace packages..." grep -A 100 "workspaces" package.json | grep -B 100 -A 1 "platform-multer"Length of output: 456
Action: Confirm Workspace Resolution in Static Analysis Tools
The dependency for
@tsed/platform-multer
is correctly declared as"workspace:*"
in theplatform-http
package'spackage.json
. However, since static analysis still fails to find it, please verify that your static analysis configuration is set up to resolve workspace dependencies properly. Double-check your tool’s module resolution settings (or any custom paths) to ensure they can locate workspace packages.
- The dependency is present in
packages/platform/platform-http/package.json
.- Static analysis failure might be due to configuration rather than an actual missing module.
🧰 Tools
🪛 GitHub Check: test-core (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-third-parties (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-security (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-platform (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-graphql (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-orm (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-specs (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.packages/platform/platform-multer/package.json (4)
1-50
: LGTM: Well-structured package configuration.The package configuration is comprehensive and properly structured with all necessary metadata, version information, and entry points.
10-29
: LGTM: Properly defined module exports.The exports field correctly defines the various entry points for the package, including framework-specific adapters for Express and Koa.
30-36
:❓ Verification inconclusive
Verify that build scripts are consistent with other packages.
The build scripts look good, but it's worth ensuring they follow the same patterns as other packages in the monorepo.
🏁 Script executed:
#!/bin/bash # Compare build scripts with other platform packages echo "Checking build scripts in other platform packages for consistency..." for pkg in packages/platform/platform-*/package.json; do if [ "$pkg" != "packages/platform/platform-multer/package.json" ]; then echo "=== $pkg ===" grep -A 10 "scripts" "$pkg" | grep -E "build|test|barrels" fi doneLength of output: 9834
Build Scripts Consistency – Platform Multer Verification
The build scripts in
packages/platform/platform-multer/package.json
match the pattern used by most other packages (e.g., using"build": "yarn barrels && yarn build:ts"
, along with the corresponding"barrels"
,"test"
,"build:ts"
, and"test:ci"
scripts).However, note that a few packages show slight differences:
- platform-exceptions: Uses
"build": "yarn build:ts"
(omitting the barrels step) and adds an extra"@tsed/barrels"
script.- platform-serverless-testing: Also omits the barrels step.
- platform-views: Displays mixed configurations across its scripts.
Please verify that these deviations are intentional and align with the specific needs of those packages. If the exceptions are by design, no changes are needed for platform-multer.
70-73
:✅ Verification successful
Verify multer version compatibility.
Using a specific version range for multer (
^1.4.5-lts.1
) - verify this is the latest stable version that's compatible with your framework.
🌐 Web query:
What is the latest stable version of multer for Node.js?
💡 Result:
The latest stable version of multer for Node.js is 1.4.5-lts.1, as listed on its npm package page [1][8]. This version was last published 3 years ago (as of the current date in March 2025) and is designated as an LTS (Long-Term Support) release.
For TypeScript users, the corresponding type definitions (
@types/multer
) are available in version 1.4.12, last updated in August 2024 [2]. Key features of multer include:
- Handling of
multipart/form-data
file uploads- Disk and memory storage engines
- Customizable filename/destination configuration
- File filtering and size limits [1][4][6]
While a 2.0.0-rc.1 release candidate exists [8], the 1.4.x LTS version remains the recommended stable choice for production environments. Developers should monitor the official npm page for future updates.
Citations:
- 1: https://www.npmjs.com/package/multer
- 2: https://www.npmjs.com/package/@types/multer
- 3: https://nodejs.org/en/about/previous-releases
- 4: https://stackabuse.com/handling-file-uploads-in-node-js-with-expres-and-multer/
- 5: https://dev.to/itsvinayak/file-uploads-made-easy-with-multer-package-in-nodejs-3mo0
- 6: https://codalien.com/blog/how-to-implement-file-uploads-in-node-js-with-multer/
- 7: https://www.npmjs.com/package/multer-s3
- 8: https://www.npmjs.com/package/multer/v/2.0.0-rc.1?activeTab=versions
- 9: https://nodejs.org/en
- 10: Nodejs Multer event fire issue expressjs/multer#136
Multer version confirmed as correct.
The dependency
"multer": "^1.4.5-lts.1"
in your package.json is indeed using the latest stable version recommended for production Node.js environments. No changes are necessary.packages/platform/platform-multer/tsconfig.esm.json (1)
1-26
: Proper TypeScript configuration for ESM module support.This configuration properly sets up the TypeScript compiler options for generating ECMAScript modules. It correctly specifies:
- The base configuration from @tsed/typescript
- Input/output directories for source and compiled files
- Declaration file generation
- Project reference support via composite:true
- Appropriate file inclusion/exclusion patterns
packages/platform/platform-multer/src/common/index.ts (1)
1-10
: Well-structured barrel file exports.This index file properly re-exports all necessary components from the platform-multer package, making imports cleaner for consumers of this library. The barrel pattern is well-implemented.
packages/platform/platform-multer/src/common/decorators/multipartFile.ts (3)
11-20
: Clean utility function implementation.The
mapOptions
function is well-designed, taking the necessary parameters and returning the properly formatted options object for multer field configuration.
22-66
: Comprehensive decorator documentation.The documentation for the
MultipartFile
decorator is excellent, providing clear examples of usage in various scenarios including single file uploads, multiple files, and with custom options.
91-91
: Clean type export for MultipartFile.The type alias is properly defined, making it easy for consumers to use the correct file type in their controllers.
packages/platform/platform-koa/src/components/PlatformKoa.ts (2)
1-2
: Properly importing multer support for Koa.The import of multer integration for Koa follows the modular approach of moving middleware functionality to dedicated packages. This helps with better separation of concerns and more targeted dependency management.
1-198
:❓ Verification inconclusive
Verify if any multipart handling methods were removed.
Based on the AI summary, a
multipart
method was removed from this file as part of moving functionality to the dedicated multer package. However, this method doesn't appear in the provided annotated code. It's important to ensure that all existing functionality has been properly migrated to the new package.
🏁 Script executed:
#!/bin/bash # Check if there was a multipart method in the previous version of this file git show HEAD~:packages/platform/platform-koa/src/components/PlatformKoa.ts | grep -A 15 "multipart(" # Check where the multipart functionality is now implemented fd -t f . -E node_modules --exec grep -l "multipart(" {} \;Length of output: 338
Ensure Proper Migration of Multipart Handling
- The current implementation in
PlatformKoa.ts
no longer includes a dedicatedmultipart
method. Instead, it imports the new@tsed/platform-multer/koa
package to handle multipart functionality.- A global search for
"multipart("
in the repository shows occurrences only in files unrelated to the Koa adapter (e.g. inPlatformAdapter.ts
andFakeAdapter.ts
), which appear to be base or testing utilities.- Since the previous commit’s reference (using
HEAD~
) could not be verified automatically, please take a moment for manual verification to confirm that any legacy multipart handling code has been fully migrated to the new multer package.🧰 Tools
🪛 Biome (1.9.4)
[error] 106-106: Don't use 'Function' as a type.
Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.
(lint/complexity/noBannedTypes)
packages/platform/platform-http/src/common/services/PlatformAdapter.ts (2)
84-88
: Good implementation of deprecated methodThe implementation correctly uses dependency injection to get the multer module and provides a clear deprecation notice. This helps users transition to the new approach while maintaining backward compatibility.
6-6
:❌ Incorrect review comment
Fix missing module dependency
The import from
@tsed/platform-multer
is causing multiple build failures as shown in the pipeline logs. This is likely because the dependency on this new package needs to be added to the package.json file.
🏁 Script executed:
#!/bin/bash # Check if @tsed/platform-multer is defined as a dependency in package.json if [ -f "packages/platform/platform-http/package.json" ]; then echo "Checking platform-http package.json for @tsed/platform-multer dependency..." grep -n "@tsed/platform-multer" packages/platform/platform-http/package.json # Check if there's a new package.json in the platform-multer directory if [ -f "packages/platform/platform-multer/package.json" ]; then echo "Found platform-multer package.json:" cat packages/platform/platform-multer/package.json else echo "No package.json found in packages/platform/platform-multer/" fi else echo "Could not find platform-http package.json" fiLength of output: 3323
Dependency already declared – please review build configuration
After verifying the package configuration, it’s clear that the dependency on
@tsed/platform-multer
is already declared inpackages/platform/platform-http/package.json
(line 86) as"@tsed/platform-multer": "workspace:*"
, and the package itself exists with its own package.json. The build failures you’re encountering are therefore unlikely to be caused by a missing dependency and may stem from workspace configuration issues or caching problems. Please double-check your build setup to ensure that the workspace dependencies are correctly resolved and, if necessary, try clearing your build cache.Likely an incorrect or invalid review comment.
🧰 Tools
🪛 GitHub Check: test-core (20.12.2)
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-third-parties (20.12.2)
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-security (20.12.2)
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-platform (20.12.2)
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-graphql (20.12.2)
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-orm (20.12.2)
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-specs (20.12.2)
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Actions: Build & Release
[error] 6-6: error TS2307: Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
packages/platform/platform-multer/tsconfig.spec.json (1)
1-37
: Well-structured TypeScript configuration for testingThe configuration extends the proper base configuration and correctly sets up all necessary paths for the test environment. The configuration includes paths to all required packages and properly configures the test environment with Vitest.
packages/platform/platform-multer/src/adapters/koa/MulterModule.ts (2)
54-71
: Well-implemented async factory patternThe implementation uses dynamic imports and a clear factory pattern to create the multer module. This approach has several benefits:
- Lazy-loading of the multer dependency
- Clear separation of concerns
- Proper encapsulation of the module functionality
73-73
: Good use of DI token registrationThe injectable decorator is properly used to register the factory as an async provider, which is the correct pattern for modules that need to be dynamically loaded.
packages/platform/platform-multer/src/common/decorators/multipartFile.spec.ts (3)
8-8
: Good refactoring of constant usageThe replacement of the middleware reference with a constant improves the code's maintainability and aligns with best practices for configurable options.
28-35
: Consistent update of test expectationsAll test expectations have been updated to use the new
PLATFORM_MULTER_OPTIONS
constant instead of the previous middleware reference. This consistency is good and ensures the tests will work correctly with the refactored code.Also applies to: 133-140, 246-253
240-240
: Good cleanup in test setupThe store cleanup properly uses the new constant, which is important for test isolation.
packages/platform/platform-http/src/common/config/interfaces/PlatformMulterSettings.ts (2)
7-22
: Good use of deprecation noticesThe code properly documents the deprecated types with clear instructions to use the equivalents from the new package.
1-6
:❓ Verification inconclusive
Missing dependency for
@tsed/platform-multer
The code imports types from
@tsed/platform-multer
, but static analysis shows that this module cannot be found in the project. This will cause build failures across multiple test suites.
🏁 Script executed:
#!/bin/bash # Check if @tsed/platform-multer is properly defined in the package.json dependencies # Look for the package in package.json echo "Checking for @tsed/platform-multer in package dependencies..." if grep -q '"@tsed/platform-multer"' package.json; then echo "✅ @tsed/platform-multer is listed in package.json" else echo "❌ @tsed/platform-multer is missing from package.json" echo "Checking workspace packages..." # Check if it's a local workspace package if [ -d "packages/platform/platform-multer" ]; then echo "✅ Found local package at packages/platform/platform-multer" ls -la packages/platform/platform-multer else echo "❌ No local package found at packages/platform/platform-multer" fi fi # Check if package-lock.json or yarn.lock has the dependency if [ -f "package-lock.json" ] && grep -q '"@tsed/platform-multer"' package-lock.json; then echo "✅ @tsed/platform-multer is listed in package-lock.json" elif [ -f "yarn.lock" ] && grep -q '"@tsed/platform-multer"' yarn.lock; then echo "✅ @tsed/platform-multer is listed in yarn.lock" else echo "❌ @tsed/platform-multer is not found in lock files" fiLength of output: 1353
Dependency Resolution Verification for
@tsed/platform-multer
- The file imports types from
@tsed/platform-multer
.- Our verification shows that although
@tsed/platform-multer
isn’t declared in the rootpackage.json
, a local workspace package exists atpackages/platform/platform-multer
and the dependency is recorded inyarn.lock
.- This indicates that dependency resolution is handled through the monorepo workspace setup rather than an explicit declaration in
package.json
.- If this behavior is intentional, please verify that your build and static analysis tools correctly interpret local workspace dependencies. Otherwise, consider explicitly adding
@tsed/platform-multer
to the package’s dependencies to avoid potential issues in environments that do not support workspace resolution.🧰 Tools
🪛 GitHub Check: test-core (20.12.2)
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-third-parties (20.12.2)
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-security (20.12.2)
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-platform (20.12.2)
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-graphql (20.12.2)
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-orm (20.12.2)
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-specs (20.12.2)
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
[failure] 6-6:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.packages/platform/platform-http/src/common/decorators/multer/multerFileSize.ts (1)
28-31
: Re-export with proper deprecation noticeThe decorator is correctly re-exported with an appropriate deprecation notice. This ensures a smooth transition for users to the new package structure.
packages/platform/platform-http/src/common/middlewares/PlatformAcceptMimesMiddleware.ts (2)
6-7
: 🧹 Nitpick (assertive)Type imports should use explicit import type syntax
For better code clarity and build optimization, consider using the explicit
import type
syntax for types-only imports.-import type {AlterEndpointHandlersArg} from "@tsed/platform-router"; -import type {JsonOperationRoute} from "@tsed/schema"; +import type {AlterEndpointHandlersArg} from "@tsed/platform-router"; +import type {JsonOperationRoute} from "@tsed/schema";Likely an incorrect or invalid review comment.
14-14
:❓ Verification inconclusive
Changed access modifier for acceptMimes
The
acceptMimes
property has been changed from public to protected, which may impact existing code that directly accesses this property. Ensure that all usages have been updated accordingly.
🏁 Script executed:
#!/bin/bash # Search for direct access to acceptMimes that might be broken by the visibility change echo "Searching for potential broken usages of 'acceptMimes' property..." rg --type-add 'ts:*.{ts,tsx}' --type ts -C 2 "\.acceptMimes\b" --glob '!**/PlatformAcceptMimesMiddleware.ts'Length of output: 4595
Changed Access Modifier for acceptMimes – Please Verify All External Usages
The
acceptMimes
property inpackages/platform/platform-http/src/common/middlewares/PlatformAcceptMimesMiddleware.ts
was changed from public to protected. A repository-wide search identified several direct references outside the middleware file:
Documentation snippets:
docs/docs/snippets/middlewares/global-middleware.ts
usesthis.acceptMimes
docs/docs/snippets/middlewares/platform-accept-mimes-middleware.ts
references the propertyTest files:
- Files in
packages/specs/schema/src/
(e.g., in JsonMethodStore and acceptMime tests) and inpackages/platform/platform-http/src/common/config/services/PlatformConfiguration.spec.ts
referenceacceptMimes
(whether on an endpoint or settings object).Please verify that these usages occur in contexts that permit protected access (such as within subclasses or internal methods). If any code is directly accessing
acceptMimes
on an instance of the middleware from an external context, consider refactoring to expose a proper getter method.docs/docs/snippets/middlewares/platform-accept-mimes-middleware.ts (1)
16-18
: Access modifier change improves encapsulation.Changing the
acceptMimes
property from public to protected enhances encapsulation by restricting direct access to this property from outside the class hierarchy.packages/platform/platform-http/src/common/services/PlatformHandler.ts (1)
3-3
: Import added for the new hook-based middleware architecture.The import of
$alter
from@tsed/hooks
is part of the shift from middleware chains to hooks.packages/platform/platform-multer/src/common/interfaces/PlatformMulterSettings.ts (3)
5-11
: Good use of module augmentation for global configuration.The declaration extends the global
TsED.Configuration
interface to include multer options, which is a clean approach for configuration extensibility.
13-14
: Clear type exports improve API consumption.Exporting type aliases for
Multer
andOptions
with platform-specific prefixes makes the API more consistent with the rest of the codebase.
15-43
: Well-documented interface for file uploads.The
PlatformMulterFile
interface is comprehensive and includes detailed JSDoc comments for all properties. This makes it clear for consumers what to expect when working with uploaded files.packages/platform/platform-multer/src/common/middlewares/PlatformMulterMiddleware.spec.ts (5)
13-13
: Function naming improvement.Renaming
build
togetFixture
better communicates the purpose of this helper function, making the test more readable.
24-29
: Good use of dependency injection for testing.The code now uses injectable factory for the MULTER_MODULE, which aligns with the new architecture and makes the test setup more maintainable.
34-36
: Updated test fixture to match new architecture.The return object now includes
multerModuleFactory
instead ofadapter
, properly reflecting the architectural changes in the codebase.
66-68
: Consistent test structure.The test for middleware with storage follows the same pattern as the basic test, which is good for maintainability.
53-55
:❓ Verification inconclusive
Verify test expectations against implementation.
The test expects the multer module to be called with specific options. Ensure this matches the actual implementation of the middleware.
🏁 Script executed:
#!/bin/bash # Check if the PlatformMulterMiddleware implementation uses multerModuleFactory.get as expected grep -A 10 "get(" packages/platform/platform-multer/src/common/middlewares/PlatformMulterMiddleware.tsLength of output: 347
Action Required: Verify
settings
Contains the Expected ConfigurationThe implementation calls
get(settings).fields(fields)
in the middleware. The test expects that the underlying multer factory’sget
method is invoked with{ dest: "/dest" }
. Please double-check that the variablesettings
is initialized with the correct options (i.e.,{ dest: "/dest" }
) so that it meets the test expectation.packages/platform/platform-http/src/common/decorators/multer/multipartFile.ts (1)
1-1
:❌ Incorrect review comment
Add
@tsed/platform-multer
to dependencies.Multiple static analysis tools are flagging that they cannot find the module
@tsed/platform-multer
. This suggests that the package might not be correctly added as a dependency in the package.json file.
🏁 Script executed:
#!/bin/bash # Check if @tsed/platform-multer is listed as a dependency in package.json echo "Checking package.json in platform-http package..." PACKAGE_JSON_PATH="packages/platform/platform-http/package.json" if [ -f "$PACKAGE_JSON_PATH" ]; then DEPENDENCY_EXISTS=$(cat "$PACKAGE_JSON_PATH" | grep -c "@tsed/platform-multer") if [ "$DEPENDENCY_EXISTS" -gt 0 ]; then echo "✅ @tsed/platform-multer is listed in package.json" cat "$PACKAGE_JSON_PATH" | grep -A3 -B3 "@tsed/platform-multer" else echo "❌ @tsed/platform-multer is NOT listed in package.json" echo "Dependencies section:" cat "$PACKAGE_JSON_PATH" | jq '.dependencies' fi else echo "❌ package.json not found at $PACKAGE_JSON_PATH" fiLength of output: 865
No action needed – dependency is already present
After running the verification, the dependency
@tsed/platform-multer
is confirmed to be listed in thepackages/platform/platform-http/package.json
file (version set as"workspace:*"
). The static analysis warnings may be due to tool configuration issues rather than an actual missing dependency. Please verify that the analysis tools are correctly set up to recognize workspace-based dependencies.Likely an incorrect or invalid review comment.
🧰 Tools
🪛 GitHub Check: test-core (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-third-parties (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-security (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-platform (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-graphql (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-orm (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.🪛 GitHub Check: test-specs (20.12.2)
[failure] 1-1:
Cannot find module '@tsed/platform-multer' or its corresponding type declarations.
import {PlatformAdapter} from "./PlatformAdapter.js"; | ||
|
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.
🧹 Nitpick (assertive)
Introduction of PlatformAdapter Import
The addition of
import {PlatformAdapter} from "./PlatformAdapter.js";
integrates the new adapter functionality into the PlatformApplication
context. Please verify that this import is actively used within the file. If its usage is strictly for type information, consider converting the statement to import type {PlatformAdapter} from "./PlatformAdapter.js";
to avoid any unnecessary runtime overhead.
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.
Nice point! I'll fix that
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.
@Romakita Thank you for confirming! I appreciate your quick agreement to fix the unused import. Converting it to a type-only import or removing it if unused will help maintain cleaner code.
(_/)
(^.^)
(> <) Thumbs up!
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
constructor(er: MulterError) { | ||
super(er.message); | ||
this.origin = er; | ||
this.name = er.code; | ||
} |
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.
🧹 Nitpick (assertive)
Consider adding type information for improved safety.
While the implementation works correctly, adding type information for the origin
property would improve type safety.
export class MulterException extends BadRequest {
+ origin: MulterError;
constructor(er: MulterError) {
super(er.message);
this.origin = er;
this.name = er.code;
}
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
constructor(er: MulterError) { | |
super(er.message); | |
this.origin = er; | |
this.name = er.code; | |
} | |
export class MulterException extends BadRequest { | |
origin: MulterError; | |
constructor(er: MulterError) { | |
super(er.message); | |
this.origin = er; | |
this.name = er.code; | |
} | |
} |
packages/platform/platform-multer/src/common/decorators/multerOptions.ts
Show resolved
Hide resolved
packages/platform/platform-multer/src/common/middlewares/PlatformMulterMiddleware.ts
Show resolved
Hide resolved
packages/platform/platform-multer/src/common/middlewares/PlatformMulterMiddleware.ts
Show resolved
Hide resolved
$alterEndpointHandlers(handlers: AlterEndpointHandlersArg, operationRoute: JsonOperationRoute) { | ||
const hasAcceptMimes = operationRoute.endpoint.acceptMimes.length || this.acceptMimes.length | ||
return { | ||
...handlers, | ||
before: [hasAcceptMimes && PlatformAcceptMimesMiddleware, ...handlers.before].filter(Boolean) as any[] | ||
}; | ||
} |
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.
🧹 Nitpick (assertive)
LGTM: Well-implemented hook function for the new middleware architecture.
The new $alterEndpointHandlers
method follows a clean, functional approach by returning a modified copy of the handlers rather than mutating the original object. The boolean check for hasAcceptMimes
properly combines conditions from both the endpoint and class properties.
// Minor readability improvement suggestion:
- const hasAcceptMimes = operationRoute.endpoint.acceptMimes.length || this.acceptMimes.length
+ const hasAcceptMimes = Boolean(operationRoute.endpoint.acceptMimes.length || this.acceptMimes.length)
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
$alterEndpointHandlers(handlers: AlterEndpointHandlersArg, operationRoute: JsonOperationRoute) { | |
const hasAcceptMimes = operationRoute.endpoint.acceptMimes.length || this.acceptMimes.length | |
return { | |
...handlers, | |
before: [hasAcceptMimes && PlatformAcceptMimesMiddleware, ...handlers.before].filter(Boolean) as any[] | |
}; | |
} | |
$alterEndpointHandlers(handlers: AlterEndpointHandlersArg, operationRoute: JsonOperationRoute) { | |
const hasAcceptMimes = Boolean(operationRoute.endpoint.acceptMimes.length || this.acceptMimes.length) | |
return { | |
...handlers, | |
before: [hasAcceptMimes && PlatformAcceptMimesMiddleware, ...handlers.before].filter(Boolean) as any[] | |
}; | |
} |
.on("alterEndpointHandlers", (handlers: AlterEndpointHandlersArg, operationRoute: JsonOperationRoute) => { | ||
handlers = this.platformMiddlewaresChain.get(handlers, operationRoute); | ||
handlers = $alter("$alterEndpointHandlers", handlers, [operationRoute]); | ||
|
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.
🛠️ Refactor suggestion
Avoid parameter reassignment.
Reassigning function parameters can lead to confusion and potential bugs. The code is replacing the middleware chain approach with a hook-based system, but the implementation should avoid reassigning the handlers
parameter.
- .on("alterEndpointHandlers", (handlers: AlterEndpointHandlersArg, operationRoute: JsonOperationRoute) => {
- handlers = $alter("$alterEndpointHandlers", handlers, [operationRoute]);
+ .on("alterEndpointHandlers", (handlers: AlterEndpointHandlersArg, operationRoute: JsonOperationRoute) => {
+ const alteredHandlers = $alter("$alterEndpointHandlers", handlers, [operationRoute]);
- handlers.after.push(useResponseHandler(this.flush.bind(this)));
+ alteredHandlers.after.push(useResponseHandler(this.flush.bind(this)));
- return handlers;
+ return alteredHandlers;
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
.on("alterEndpointHandlers", (handlers: AlterEndpointHandlersArg, operationRoute: JsonOperationRoute) => { | |
handlers = this.platformMiddlewaresChain.get(handlers, operationRoute); | |
handlers = $alter("$alterEndpointHandlers", handlers, [operationRoute]); | |
.on("alterEndpointHandlers", (handlers: AlterEndpointHandlersArg, operationRoute: JsonOperationRoute) => { | |
- handlers = $alter("$alterEndpointHandlers", handlers, [operationRoute]); | |
+ const alteredHandlers = $alter("$alterEndpointHandlers", handlers, [operationRoute]); | |
- handlers.after.push(useResponseHandler(this.flush.bind(this))); | |
+ alteredHandlers.after.push(useResponseHandler(this.flush.bind(this))); | |
- return handlers; | |
+ return alteredHandlers; | |
}) |
🧰 Tools
🪛 Biome (1.9.4)
[error] 35-35: Reassigning a function parameter is confusing.
The parameter is declared here:
Use a local variable instead.
(lint/style/noParameterAssign)
buffer: Buffer; | ||
} | ||
|
||
export type PlatformMulterField = Field; |
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.
🧹 Nitpick (assertive)
Consider adding JSDoc for PlatformMulterField
While the PlatformMulterFile
interface has thorough documentation, the PlatformMulterField
type lacks similar documentation. Adding JSDoc comments would maintain consistency and improve developer experience.
+/**
+ * Field configuration for multipart file uploads.
+ */
export type PlatformMulterField = Field;
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
export type PlatformMulterField = Field; | |
/** | |
* Field configuration for multipart file uploads. | |
*/ | |
export type PlatformMulterField = Field; |
@@ -60,29 +46,7 @@ | |||
* @returns Function | |||
* @decorator | |||
* @input | |||
* @deprecated use MultipartFile from @tsed/platform-multer |
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.
🧹 Nitpick (assertive)
Clarify the deprecation notice.
The deprecation notice suggests using MultipartFile
from @tsed/platform-multer
, but since this file is re-exporting the same decorator, it might be confusing for users. Consider clarifying that the local implementation is deprecated while the re-export will still work.
- * @deprecated use MultipartFile from @tsed/platform-multer
+ * @deprecated This local implementation is deprecated. This import will still work as it re-exports from @tsed/platform-multer, but you can also directly import from @tsed/platform-multer if preferred.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
* @deprecated use MultipartFile from @tsed/platform-multer | |
* @deprecated This local implementation is deprecated. This import will still work as it re-exports from @tsed/platform-multer, but you can also directly import from @tsed/platform-multer if preferred. |
export const MultipartFile: typeof M = M; | ||
export type MultipartFile = typeof M; |
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.
🧹 Nitpick (assertive)
Improve type definition consistency.
The type definition is unusual. It's defining MultipartFile
as the type of the type of M
. For better consistency and clarity, consider one of the following approaches:
- Import the type directly from
@tsed/platform-multer
- Use the direct type annotation rather than referring to the type of the imported value
Option 1:
import {MultipartFile as M} from "@tsed/platform-multer";
+ import type {MultipartFile as MType} from "@tsed/platform-multer";
export const MultipartFile: typeof M = M;
- export type MultipartFile = typeof M;
+ export type MultipartFile = MType;
Option 2:
export const MultipartFile: typeof M = M;
- export type MultipartFile = typeof M;
+ // Using the same type as the imported decorator
+ export type MultipartFile = Parameters<typeof M>[0] extends (target: any, propertyKey: string, index: number) => void ? Parameters<typeof M>[0] : never;
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
export const MultipartFile: typeof M = M; | |
export type MultipartFile = typeof M; | |
import {MultipartFile as M} from "@tsed/platform-multer"; | |
import type {MultipartFile as MType} from "@tsed/platform-multer"; | |
export const MultipartFile: typeof M = M; | |
export type MultipartFile = MType; |
Information
Move multer code to his own package
Summary by CodeRabbit
New Features
Refactor
Tests
Chores