The last LTS releases for LoopBack were a couple of months ago. In January, the team updated loopback-datasource-juggler and strong-remoting.  The team implemented several changes into the open source framework this month as well. Curious about what the changes in the latest LoopBack release? Miroslav Bajtos provided a rundown of what’s new in the latest LoopBack release – 2.38.1 (LTS):

What's New Latest LoopBack Release March 2017

Improve “filter” arg description

Add an example showing how to serialize object values as JSON.

Fix creation of verification links

Fix User.prototype.verify to call querystring.stringify instead of concatenating query-string components directly.

In particular, this fixes the bug where options.redirect containing a hash fragment like #/home?arg1=value1&arg2=value2 produced incorrect URL, because the redirect value was not correctly encoded.

Include link to docs in logoutSessions warning

Make it easy for people encountering the long warning about “logoutSessionsOnSensitiveChanges” to find the relevant information in our documentation.

Preserve sessions on User.save() making no changes

Fix session-invalidation code to correctly recognize the case when User.save() was called but neither password nor email was changed.

Modify the code detecting whether logoutSessionsOnSensitiveChanges is enabled to correctly handle the case when the model is not attached to any application, as is the case with loopback-component-passport tests.

Fix logout to handle missing or unknown accessToken

Return 401 when the request does not provide any accessToken argument or the token was not found.

Also simplify the implementation of the logout method to make only a single database call (deleteById) instead of findById + delete.

Role model: resolve related models by name

Resolve models related to the Role model by name instead of class instance. This allows to use localRegistry in app without monkeypatching Role manually.

When loading the Role model into a custom registry (e.g. by setting localRegistry to true when instantiating the app object), static roles can not be resolved because the RoleMapping model used inside static methods (e.g. Role.isInRole()) is loaded into a different registry (i.e. loopback) and thus not attached to any dataSource. The patch changed code resolving models related to the Role model to use model name instead of a global model constructor, which leads to them being resolved from the same registry that Role is loaded in as well.

Fix User methods to use correct Primary Key

Do not use hard-coded “id” property name, call idName() to get the name of the PK property.

Enable remote methods to be disabled by alias

Fix disableMethodByName method to allow callers to specify one of method aliases instead of the “canonical” name. For example, disable the method removeById by calling disableMethodByName('destroyById').

Fix content-type reported by the built-in error handler

In order to match the body contents, the content-type is reset back to application/json now when a remote method sets a custom content-type (e.g. image/jpeg) and then fails.

Convert object query params to JSON in outgoing requests

When invoking a remote method via strong-remoting, fix the code building query string parameters to correctly handle edge cases like a deeply-nested empty-array value.

Consider the following invocation:

Model.find({where: {id<: {inq: []}}})

An empty argument value was sent before the fix.

strong-remoting is sending the correct argument value now.

Fix datasource to report connector-loading errors

All errors used to be ignored when resolving full connector path. As a result, when the connector was installed but not correctly built (e.g. loopback-connector-db2 which uses a native addon), a very confusing message was reported by LoopBack.

We fixed the code handling require() errors to ignore only MODULE_NOT_FOUND errors that contain the name of the required module.

What’s Next?

Want to know more about these changes? You can visit the LoopBack github repo for full details about these updates as well as code, the LoopBack wiki, and more.

Also, expect more announcements about LoopBack soon!