-
Notifications
You must be signed in to change notification settings - Fork 474
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
perf: added possibility to lazy initialize the document #2392
perf: added possibility to lazy initialize the document #2392
Conversation
@micalevisk Yeah, I think your way could be better since I don't need to add more options to |
@micalevisk suggestions looks good! Also, @H4ad would you like to create a PR to the docs (describing this feature)? |
c1f7931
to
448ff1a
Compare
Updated with the new version, it was cleaner than the older version. |
Docs PR: nestjs/docs.nestjs.com#2704 |
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.
Just some minor corrections for code identation, for the rest is ok 👍
chore(lib): fix style Co-authored-by: Antonio Tripodi <Tony133@users.noreply.github.com> chore(lib): fix style Co-authored-by: Antonio Tripodi <Tony133@users.noreply.github.com> chore(lib): fix style Co-authored-by: Antonio Tripodi <Tony133@users.noreply.github.com> chore(lib): fix style Co-authored-by: Antonio Tripodi <Tony133@users.noreply.github.com> chore(lib): fix style Co-authored-by: Antonio Tripodi <Tony133@users.noreply.github.com> chore(lib): fix style Co-authored-by: Antonio Tripodi <Tony133@users.noreply.github.com> fix: issue with swagger module on undefined variable
c247a0d
to
e876270
Compare
Fixed issues with e2e tests! |
It seems that the PR caused this regression #2481 |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Currently, NestJS builds the Swagger document synchronously on startup, which it's a waste of time since we don't care about the swagger routes until we need to make a call to it.
What is the new behavior?
So, I added an option to lazy initialize the Swagger document, the document will only be built when we have some request for it.
In my API, it reduced about 70~75ms from initialization, it will vary according to the API and the amount of routes but now it will only take 2ms to initialize the Swagger Module.
Usage
Now, to use the new lazy loading feature, just change these lines:
Just one line to use it.
Reproduction
To use it: https://stackblitz.com/edit/nestjs-starter-bql4af?file=src/main.ts
Does this PR introduce a breaking change?