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

Spike: From datasource config to Service REST API with no proxy/controller classes #2481

Closed
5 tasks
bajtos opened this issue Feb 26, 2019 · 3 comments
Closed
5 tasks

Comments

@bajtos
Copy link
Member

bajtos commented Feb 26, 2019

In LoopBack 3, it was very easy to get a fully-featured CRUD REST API with very little code: a datasource configuration for a 3rd party webservice (REST, SOAP, etc.) and an empty model attached to that datasource.

Let's provide the same simplicity to LB4 users too and build on top of the mechanism implemented for models in #2036.

  • User creates a datasource using a web-service connector like REST or SOAP. (No change here.)
  • User declaratively defines how to expose this service via REST API. At minimum, we need a model name or URL path where to mount the service API.
  • @loopback/boot processes this configuration and registers appropriate service proxies & controllers with the app.

Note: having config for multiple services in a single JSON file can quickly become a maintenance nightmare, see strongloop/loopback#1316. It will be better to have one config file per service, e.g. public-services/geocoder.json.

See also

Acceptance criteria

A pull request with a proof-of-concept implementation showing how to achieve the goals listed above.

  • A new extension (npm package living in loopback-next monorepo) mapping strong-remoting metadata to OpenAPI spec. Connectors are using strong-remoting metadata to describe the shape of the remote API. In LoopBack4, we are using OpenAPI spec instead, and thus need a bridge that will allow LB4 to understand metadata provided by connectors.

    Implementation-wise, the PoC can leverage the code from RFC: use LB3 models in an LB4 app [SPIKE - DO NOT MERGE] #2274, see lb3-openapi.ts. That code is based on loopback-swagger package from LB3.

    In this spike, we should figure out how to package this code into a standalone extension, how to migrate the test suite from loopback-swagger and also what we need to implement on top of the current PoC version to make it good enough for SOAP/REST/Swagger connectors.

    IMPORTANT: In RFC: use LB3 models in an LB4 app [SPIKE - DO NOT MERGE] #2274, we are using strong-remoting's SharedClass and SharedMethod APIs to process remoting metadata. IIRC, connectors don't use those APIs and put remoting metadata directly into properties of a remote method (this is an older flavor from LB 1.x). If that's the case, then the new extension should process the remoting metadata directly, so that we don't have to re-create SharedClass/SharedMethod classes in LB4 again.

  • A component to build a controller class or a set of route handler for given remoted class (data-access-object constructor as provided by a connector).

    In this spike, start by reusing and repackaging the existing code in RFC: use LB3 models in an LB4 app [SPIKE - DO NOT MERGE] #2274, see lb3-model-controller.ts and rest-adapter.ts.

    Again, try to find a solution that does not need SharedClass and SharedMethod classes.

  • A new extension providing a booter that parses public-services JSON files and exposes the services as configured.

  • An example application using REST or SOAP connector and demonstrating the PoC solution end-to-end.

  • A list of follow-up stories for the actual implementation. In addition to runtime parts, these stories should also cover:

    • A new CLI command that will ask the user for an existing datasource, model name or URL path, and then generate the corresponding public-services entry.

    • Documentation

    • Blog post

@jannyHou
Copy link
Contributor

time box it to 8 days

@bajtos bajtos added p1 and removed p1 labels Apr 9, 2019
@dhmlau dhmlau added 2019Q3 and removed 2019Q2 labels Apr 16, 2019
@dhmlau dhmlau added 2019Q4 and removed 2019Q3 labels Jun 25, 2019
@bajtos bajtos added the p2 label Sep 12, 2019
@dhmlau dhmlau added p3 and removed p2 labels Sep 24, 2019
@dhmlau dhmlau added 2020Q1 and removed 2019Q4 labels Oct 3, 2019
@dhmlau dhmlau added 2020Q2 and removed 2020Q1 labels Nov 15, 2019
@dhmlau dhmlau added 2020Q3 and removed 2020Q2 labels Feb 17, 2020
@dhmlau dhmlau added the p3 label Jul 28, 2020
@stale
Copy link

stale bot commented Jul 14, 2021

This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository. This issue will be closed within 30 days of being stale.

@stale stale bot added the stale label Jul 14, 2021
@stale
Copy link

stale bot commented Aug 13, 2021

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

@stale stale bot closed this as completed Aug 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants