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: Booter for creating REST APIs from model files #2738
Comments
11 tasks
Timebox for a week and a half. @bajtos question from estimation (Janny); Does the spike's scope have generation of relational APIs for the models if they're defined? Estimation is based on not including relational APIs. |
This was referenced Aug 26, 2019
WIP proposal: #3617 |
Follow-up stories:
I am closing the spike as done. |
This was referenced Sep 26, 2019
3 tasks
7 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Part of From model definition to REST API with no custom repository/controller classes #2036
In #2736, we will implement a component providing CRUD REST Controller class that can be used to expose models via REST API.
In this spike, we will find out how to implement a booter that will read model configuration from JSON files, load controllers contributed by extensions, and connect those two parts together to expose REST APIs.
Prerequisites
(1)
An extension exporting a Controller, e.g. #2736. We can build a minimal version of such extension as part of this spike if needed.
(2)
Configuration format. Let's start with the convention described in #2036. If it turns out to be difficult to implement, then propose a better one.
For example, to create a
Product
model, attach it to adb
datasources and expose a CRUD REST API, all that the developer needs is to add the following two files to their project (plus any npm packages that implement this functionality):src/models/product.ts
:public-models/product.json
:Note: having config for multiple models in a single JSON file, as we do in LB 3.x, can quickly become a maintenance nightmare - see strongloop/loopback#1316. It will be better to have one config file per model.
An example file for a model using KeyValue pattern (not CRUD) -
public-models/cache-entry.json
:IMPORTANT: Keep in mind that TypeScript compiler does not copy arbitrary JSON files from
src
todist
. A possible solution is to keep model configuration files in/public-models
directory (outside of/src
).Acceptance criteria
A design proposal and PoC implementation showing how extensions can contribute controllers that can be picked by a Booter. Preferably leverage ExtensionPoint/Extension pattern as shown by our greeter example.
A PoC implementation of a booter parsing model configuration files, gathering controllers contributed by extensions, and using this information to build REST APIs for models as configured. Implementation-wise, start with the approach outlined in From model definition to REST API with no custom repository/controller classes #2036 (comment).
How to deal with Repositories?
CrudRestController
requiresCrudRepository
,CrudKeyValueController
requiresKeyValueRepository
. We need a way (or a convention) allowing extension developers building different controller implementations to specify which repository should be used.The text was updated successfully, but these errors were encountered: