Skip to main content

LoopBack 4 March 2020 Milestone Update

· 8 min read
Agnes Lin

Originally published on

The whole world has been through a lot in the past month. The LoopBack team hopes that everyone stays safe and gets through this together.

Let's check out the work we did in March:

Migration Guide

As LoopBack 3 will go end of life at the end of 2020, we've been focusing on the migration guide for the past months. Here is the content we added in March to help LB3 users adopt LoopBack 4:

Migrating Built-in Authentication

In LoopBack 3, the authentication system is a token-based one and has built-in models involved in the mechanism. In LB4, we built a more flexible authentication system that is compatible with different authentication strategies. Even though there are lots of differences, the newly created access control migration example explores how to migrate and build an equivalent LoopBack 3 authentication system in LoopBack 4 with detailed steps. The tutorial includes two main parts:

  1. How to migrate the LoopBack 3 User model's definition and its persistence and login endpoint.
  2. How to secure endpoints using a token based authentication system and enable the authorize dialog in the API explorer like what we have in LoopBack 3.

The tutorial also uses the handy LB4 CLI to help LB3 users to get familiar with LB4 terms. Read the migration-authentication tutorial to learn about the details.

Features Not Planned for LoopBack 4

Besides migrating artifacts from LB3, there are several features/components we no longer support anymore in LB4. They are listed in the page LoopBack 3 features not planned in LoopBack 4. We also provide workarounds for these features if users would like to continue using them in LB4.

From Model to REST API

The story From Model to REST API with no custom repository/controller epic is almost done! In the past few months, we created the @loopback/rest-crud package, as well as the the ModelApiBooter booter. And this month, we built the CLI command lb4 rest-crud. To glue these pieces together, we added an example and documentation to help you pick up this convenience tool. Details are listed below. We will have a blog post in the near future.

CLI Command

In order to make it easier for users to use this feature, we've added a CLI command to simplify the process. If you have model classes and a valid(persisted) datasource, the following command will generate model endpoints for you:

lb4 rest-crud

Example Application

We've added a new rest-crud example which creates the Todo example without the need to define a repository or controller for the Todo model. By loading the CrudRestComponent, it demonstrates how to use the default CRUD REST repository and controller with a single model class , datasource, and configuration. The example can be downloaded by running:

lb4 example rest-crud

You can find more information on how to use the command in the REST CRUD generator documentation.


Now that most of the epic is completed, we've added documentation explaining how to use the feature and the configuration options that come with it. Additionally, we also added documentation on extending the @loopback/model-api-builder package to create your own custom model API builders; similar to @loopback/rest-crud's CrudRestApiBuilder.

More Usage Scenarios

We've been adding more examples to show what you can build with, and how you can configure a LoopBack 4 app. One of our favorite examples is the Shopping App. It shows how you can integrate LB4 APIs with a simple front-end design to build a site. Besides the rest-crud example mentioned above, we added more examples to show various LoopBack 4 features.

Validation Example

LB4 allows you to add validations at three different layers: REST, controller, and ORM. The newly added documentation Validation explains these three different types of validations. We added a corresponding example Validation Example to our Examples list demonstrating how to add and make use of different kinds of validations in a LoopBack 4 application.

File Upload and Download Example

Uploading/downloading files is a common requirement for API applications. The documentation for Upload and download files shows the code snippets to create artifacts such as controllers and UI to achieve such a requirement. A fully-functional example is available at File Transfer Example.

Documentation Enhancement

We made some changes in the layout design of the website. Hope you like the new look!

Request Response Cycle

To help users have a better understanding of all the components involved in the request-response handling process, in the Request-Response cycle document, we walk through the path taken by a request to see how it makes its way through the various parts of the framework to return a result. In the near future, we will also add documentation in the migration guide to explain the differences of the request-response cycle between LB3 and LB4. See the GH story Migration Guide: Request-response cycle for more details.


We made the CHANGELOG easier to find on our site. It is available in the section CHANGELOG. We hope it helps developers to check out the changes of different packages for each release.


User Testimonials

We're glad to see a growing number of user testimonials. We refactored it in a new page. Check out the what our users say section. Let us know if you would like to tell us about your LoopBack usage!

IBM i Connector

The IBM Db2 for i connector was added to the connector list. You can now conveniently create an IBM Db2 for i datasource using our CLI. See the Db2 for i connector page for more details.

Newly Added Extensions

Here are the extensions we added to the framework:

The IBM API Connect OpenAPI enhancer @loopback/apiconnect extension was added to extend LoopBack with the ability to integrate with IBM API Connect.

An experimental extension @loopback/cron was added. With it, LB4 apps can be integrated with Cron to schedule jobs using cron based schedules.

Extracting JWT Component

After creating the demo for JWT authentication in loopback4-example-shopping and applying a similar system in loopback-example-access-control, we think it's time to extract the JWT authentication system into a separate component. This will benefit users who want to quickly mount a prototype token based authentication module to their application. As the first step, we extracted the JWT strategies, the token, and user services into a local module under components/jwt-authentication. Next we will move it to a standalone extension package. Feel free to join the discussion in GH story Extract the jwt authentication to an extension module.

Supporting Type Any

Model property of type any is now supported. The corresponding OpenAPI and JSON schema is {} or true (according to the draft JSON schema standard). If your model property allows arbitrary values, now you can define it as:

class MyModel extends Entity {
// ...other code
// specify the type name here as 'any'
type: 'any'
// use `any` as its TypeScript type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
anyProperty: any

Bug fixes

  • We fixed a bug in module @loopback-ibmdb where a put request PUT /Model/{instanceId} now operates correctly. The fix trickles down into any LoopBack connector with a dependency on @loopback-ibmdb like @loopback-connector-db2 and @loopback-connector-dashdb, for example.

  • We fixed a bug in connector @loopback-connector-mssql which was causing permission problems during installation on Windows. Some extra folders ended up in the package tgz file, and this was causing the problem. The fix went out for several LoopBack connectors: MSSQL, DB2, dashDB, Cloudant, MongoDb, MySQL, Oracle, PostgreSQL, and Redis KeyValue.

Community Contribution

Our community maintainers and users have been very helpful with building a better LoopBack 4, we really appreciate all the help! Here are the highlights this month:

Enable Authentication Strategies to Contribute OASEnhancer

The community maintainer dougal83 improved the authentication strategies AuthenticationStrategy so that it can be bound with the OAS enhancer extension point via a binding key instead of a constant.

Japanese Translation for LB4

The community user saotak added several LB4 pages in Japanese. See the site. We need your help to have more translations for the LB4 documentations! The instructions can be found in the page Translation.

Call to Action

In 2020, we look forward to helping you and seeing you around! 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: