-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
docs: create REST API endpoints in components + LB3 migration #5385
Conversation
REST API explorer has a flag `useSelfHostedSpec` that controls whether a new | ||
endpoint serving OpenAPI document is added. | ||
|
||
## Dynamic OpenAPI metadata |
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.
We could use https://loopback.io/doc/en/lb4/Booting-an-Application.html#boot-an-application-using-component for some of the use cases. I was able to modify the binding key and other metadata for services/controllers/... loaded by booters by override the app.service()
, app.controller()
for the subapp.
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.
Thank you for the pointer, I agree "booting an app using component" is a concept that can be useful when migrating LB3 extensions to LB4. However, I don't see how to apply it to "Dynamic OpenAPI metadata". I opened a new issue to document "booting an app using component" for extension authors in a holistic way - see #5422
Express router in your LoopBack 4 component and contribute it to the target | ||
application. | ||
|
||
2. Take the implementation of Express routes from your LoopBack 3 component and |
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.
Express routes can be added to a router
using router.use()
. The router
can be plugged into LoopBack as an ExpressRequestHandler (express middleware handler function).
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.
Express routes can be added to a router using
router.use()
.
I am going to clarify this in https://github.com/strongloop/loopback-next/blob/docs/component-migration-rest-api/docs/site/extending/rest-api.md#express-routes
The
router
can be plugged into LoopBack as an ExpressRequestHandler (express middleware handler function).
I am not familiar with this new style. For now, I am recommending app.mountExpressRouter()
, which has the benefit of allowing users to provide OpenAPI spec description of the Express routes too.
I opened #5423 to update the docs for extension authors and explain when & how to use this new concept.
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.
Added a few minor comments. Great write-up.
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 content! LGTM, a few nitpicks. 🚢
- Create a new page for component authors to explain how to contribute REST API endpoints - Create a new page for component authors to explain how to contribute local service classes or providers - Create a migration guide explaining how to migrate REST API endpoints from LoopBack 3 components to LoopBack 4 style. Signed-off-by: Miroslav Bajtoš <[email protected]>
4f2ec43
to
43affa4
Compare
Thank you @raymondfeng and @jannyHou for the review and comments, I highly appreciate them 👍 |
This is a part of documentation for the spike #4099 How to migrate LB3 components.
In this pull request, I am covering migration of REST API endpoints.
This is a part of a spike, so I should not be changing the real docs, but then I figured out that since I have already wrote the content, it will give more value to our users to put the content up, even if it's not finished yet. My intention is to land this pull request even if the content is not in the shape we would eventually want and create follow-up stories to make any substantial improvements as required by reviewers. (This the the part where I am getting back to our usual spike process - do the research and then open follow-up stories to implement the proposed changes.)
@raymondfeng @jannyHou @emonddr: please review
Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm test
passes on your machinepackages/cli
were updatedexamples/*
were updated👉 Check out how to submit a PR 👈