Skip to main content

LoopBack 4 October 2019 Milestone Update

· 7 min read
Dominique Emond

Originally published on strongloop.com

As the cold autumn winds and frost nipped at our heels, the LoopBack team kept warm with generous portions of hot tea and coffee and accomplished their planned October milestone goals.

We focused on the following areas:

  • Inclusion of related models
  • Adding Partitioned Database Support for Cloudant and CouchDB connector
  • Spike on Migration Guide
  • Improvements to Shopping Cart Example
  • CASCON x Evoke 2019 Workshop Preparation
  • Repository Tests for PostgreSQL
  • Generating Controller/Repository from a Model
  • Documentation Improvements
  • Bug fixes / CI fixes

See the October milestone for an overview of what we have worked on, and read on for more details.

Also, we were honored this month when API World awarded LoopBack with the 2019 Best of API Middleware Award. Raymond Feng was there to accept the award on behalf of the team. Yay, team!

We've been working on inclusion resolvers for relations for the past several months. Besides the basic functionality, we also added a prompt for activating the inclusion resolver for the lb4 relation command in PR #3856. This allows users to easily set up the inclusion resolver through the CLI just like all others artifacts.

The lb4 relation command now prompts to confirm if an inclusion resolver should be registered for the given relation.

Also, we posted a blog to illustrate the idea and usage of the inclusion resolver. We have a full example from setting up the models and relations through CLI, to querying data with the inclusion resolver. Read the blog to try out the feature!

We've gotten feedback from the community since this feature was published. As a result, we've improved the documentation. Diagrams were added to each relation to make the concept more intuitive. We also added URLs as examples to query related models in case users want to process data at the controller level instead of the repository level. See PR #4007 for more details.

Adding Partitioned Database Support for Cloudant and CouchDB connector

Spike

Both Cloudant and CouchDB support partitioned databases which make querying less expensive - computationally in CouchDB, monetarily on Cloudant (on IBM Cloud).

A spike was performed to investigate the work required to support the partitioned database in Cloudant, and follow-up tasks were created. Epic #219 - Add support for partitioned database was created to track the implementation stories.

The feature will be supported in 3 stages. In the first stage, we will update the driver and enable creating the partitioned index; which are the pre-requisites for the partitioned search. The second stage includes supporting the query with partition key from the options data or the payload data; the latter one requires a model property defined as the partition key field. Stage 3 contains more improvements for the document creation in the partitioned database by supporting a composed ID.

Updating Driver

To start Epic #219, we updated the cloudant driver and the docker image to the latest ones which support the partition feature.

Spike on Migration Guide

A spike was performed on migrating from LoopBack 3 to LoopBack 4. As a result, we created the outline of a migration guide.

Improvements to Shopping Cart Example

The shopping cart application has undergone a few improvements.

  • We have added an out-of-the-box capability to set a JWT token via an Authorize button/dialog in the API Explorer. When interacting with the secured endpoint, the token is automatically sent in the Authorization header of the request. See PR #301 and PR #3876 for details. To find out how to enable this capability in your application, please see Specifying the Security Settings in the OpenAPI Specification.

  • The shopping cart application has been decomposed into multiple microservices, each of which is packaged as a docker image. It's possible to communicate between microservices using REST and/or gRPC. A helm chart can now be used to deploy these microservices to a Kubernetes cluster on Minikube or IBM Cloud. See Deploy the Shopping Application as Cloud-native Microservices using Kubernetes for more details.

  • The shopping service can now connect to the recommender service over gRPC as well as REST. See PR #333 for details.

  • Extra logic was added to *.datasources.ts files to accept configuration from kubernetes environment variables. See PR #338 for details.

CASCON x Evoke 2019 Workshop Preparation

The LoopBack 4 team has prepared material for a booth and workshop at CASCON x Evoke 2019 in Toronto, Canada. We hosted a booth named REST APIs with LoopBack 4 and OpenAPI 3 on November 4th and 6th and held a workshop named Write scalable and extensible Node.js applications using LoopBack 4 on November 5th. Watch for an upcoming blog post with an overview of the event!

Repository Tests for PostgreSQL

Previously, we ran repository tests against the memory, MySQL, and MongoDB databases. This month, we added PostgreSQL to the databases these tests are run against. You can see PR #3853 for details or take a look at the newly added repository-postgresql package.

Generating Controller/Repository from a Model

Some progress was made on the EPIC #2036 - From model definition to REST API with no custom repository/controller classes. A controller can now be generated based on a model name. See PR #3842 for details. Also, a repository can now be generated based on a model name. See PR #3867 for details.

Documentation Improvements

New 'Inside a LoopBack Application' Section Added to Docs

We're always seeking to improve our documentation. We've added a new section Inside a Loopback Application to help LoopBack 4 application developers to establish a high level understanding of how LoopBack 4 is related to their application requirements.

Customize Id and Foreign Key Names for Relations

After triaging some issues from the community, we realized that the documentation for customizing key names needs to be enhanced. We added explanations and examples to illustrate the default value of relations, how to customize key names, and how to use different names for models and database columns. You can find more details in HasMany - Relation Metadata, HasOne - Relation Metadata, and Defining a belongsTo Relation.

Bug Fixes / CI Fixes

Looking for User References

As a LoopBack user, do you want your company highlighted on our web site? If your answer is yes, see the details in this GitHub issue.

What's Next?

If you're interested in what we're working on next, you can check out the November Milestone.

Call to Action

LoopBack's success depends on you. We appreciate your continuous support and engagement to make LoopBack even better and meaningful for your API creation experience. Here's how you can join us and help the project: