Skip to content
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

feat: support using custom multer instance in RegisterRoutes #1638

Conversation

midoelhawy
Copy link

@midoelhawy midoelhawy commented Jun 6, 2024

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you written unit tests?
  • Have you written unit tests that cover the negative cases (i.e.: if bad data is submitted, does the library respond properly)?
  • This PR is associated with an existing issue?

Closing issues

closes #1483

If this is a new feature submission:

  • Has the issue had a maintainer respond to the issue and clarify that the feature is something that aligns with the goals and philosophy of the project?

Potential Problems With The Approach

Test plan

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hello there midoelhawy 👋

Thank you and congrats 🎉 for opening your first PR on this project.✨

We will review the following PR soon! 👀

@midoelhawy midoelhawy marked this pull request as draft June 6, 2024 23:00
@midoelhawy midoelhawy marked this pull request as ready for review June 6, 2024 23:02
@WoH
Copy link
Collaborator

WoH commented Jun 21, 2024

LGTM, but can you add a test in one of the setups maybe?

@midoelhawy
Copy link
Author

Hi @WoH,

Makes sense. I've now added the automatic tests to avoid bad configuration errors:

cross-env NODE_ENV=tsoa_test mocha "./integration/express-server-custom-multer.spec.ts"

  Express Server With custom multer
    file upload With custom multer instance
      ✔ can post a file (71ms)
      ✔ can post a file without name
      ✔ cannot post a file with wrong attribute name
      ✔ can post multiple files with other form fields
      ✔ can post single file to multi file field
      ✔ can post multiple files with different field
      ✔ can post multiple files with different array fields
      ✔ can post mixed form data content with file and not providing optional file
      ✔ can post mixed form data content with file and provides optional file

  9 passing (239ms)

Thanks!

Ahmed Hekal added 2 commits July 3, 2024 01:36
…' of github.com:midoelhawy/tsoa into support-using-custom-multer-instance-in-register-routes
@midoelhawy
Copy link
Author

Hi @WoH,

There were some ESLint errors outside my edited files, but they were resolved by merging master into my branch. Everything works now.

Can you run the tests again, please?

@midoelhawy
Copy link
Author

Hi @WoH,

These errors are related to @typescript-eslint rules. They appeared only after cleaning the yarn.lock, so I think they're related to some new @typescript-eslint patch.

/home/work/tsoa/tsoa/packages/cli/src/metadataGeneration/transformer/referenceTransformer.ts
17:40 error This assertion is unnecessary since it does not change the type of the expression @typescript-eslint/no-unnecessary-type-assertion
21:35 error This assertion is unnecessary since it does not change the type of the expression @typescript-eslint/no-unnecessary-type-assertion

/home/work/tsoa/tsoa/packages/cli/src/metadataGeneration/typeResolver.ts
144:43 error This assertion is unnecessary since it does not change the type of the expression @typescript-eslint/no-unnecessary-type-assertion

/home/work/tsoa/tsoa/packages/cli/src/swagger/specGenerator2.ts
441:54 error This assertion is unnecessary since it does not change the type of the expression @typescript-eslint/no-unnecessary-type-assertion

/home/work/tsoa/tsoa/packages/cli/src/swagger/specGenerator3.ts
105:28 error This assertion is unnecessary since it does not change the type of the expression @typescript-eslint/no-unnecessary-type-assertion

I fixed them by ignoring the errors in some cases and by fixing the types when possible.

Can you run the Build action again, please?

@WoH
Copy link
Collaborator

WoH commented Jul 12, 2024

LGTM, thanks for your contribution, and, tbh, your patience

@WoH WoH merged commit bc648c1 into lukeautry:master Jul 12, 2024
18 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.

Add ability to inject our custom multer instance to tsoa
2 participants