All breaking changes must be described here. When adding a new entry, always describe the impact on users and instructions for upgrading applications from 2.x to 3.0.
Originally, we (ab)used peer dependencies to ensure there is only one instance of loopback-datasource-juggler in the dependency tree, so that there is only one singleton instance of model registry. This was very fragile and might not have worked in certain edge cases.
We have reworked loopback-datasource-juggler and connectors to not rely on a single juggler instance anymore. As the last step, juggler became a regular dependency.
When upgrading application from previous loopback versions, simply remove loopback-datasource-juggler from your dependencies.
In version 3.0, we always use bluebird as our promise library
instead of global.Promise
.
We consider Bluebird API a part of LoopBack API from now on,
you are welcome to use any Bluebird-specific methods in your applications.
If you are using LoopBack with a custom promise implementation provided
via global.Promise
,
you will have to check all places where you are using non-standard promise API
and update them to use Bluebird API instead.
Please see Related code change here.
In 2.0, remote methods were defined as:
methods: {
staticMethod: {
isStatic: true,
http: { path: '/static' }
},
instanceMethod: {
isStatic: false,
http: { path: '/instance' }
}
}
For 3.0, the isStatic flag is no longer required and will be determined from the method name. Method name starting with "prototype." will be the same as having isStatic flag set to false.
methods: {
staticMethod: {
http: { path: '/static' }
},
'prototype.instanceMethod': {
http: { path: '/instance' }
}
Please see related code change here.
Change.handleError
is now removed as it was used inconsistenly for a subset of possible
errors only. All Change methods will report all errors to the caller via the callback.
Use PersistedModel to report change-tracking errors via the existing method PersistedModel.handleChangeError. This method can be customized on a per-model basis to provide different error handling.
Please see related code change here.
The following properties are removed from the built-in User model in 3.0:
- credentials
- challenges
- status
- created
- lastUpdated
Developers that are relying on these properties, can redefine them in user.json
or equivalent model.json as follow:
{
"name": "MyUser",
"base": "User",
"properties": {
"credentials": { "type": "object" },
"challenges": { "type": "object" },
"status": "string",
"created": "date",
"lastUpdated": "date"
}
}
Please see Related code change here.
Express 4.x stopped bundling commonly-used middleware. To simplify migration of LoopBack 1.x applications (powered by Express 3.x) to LoopBack 2.x (powered by Express 4.x), we created getter properties to allow developers to keep using the old convention.
We have removed these getters in LoopBack 3.0, here is the full list of removed properties together with the middleware module name to use instead:
loopback.compress
- userequire('compression')
insteadloopback.timeout
- userequire('connect-timeout')
insteadloopback.cookieParser
- userequire('cookie-parser')
insteadloopback.cookieSession
- userequire('cookie-session')
insteadloopback.csrf
- userequire('csurf')
insteadloopback.errorHandler
- userequire('errorhandler')
insteadloopback.session
- userequire('express-session')
insteadloopback.methodOverride
- userequire('method-override')
insteadloopback.logger
- userequire('morgan')
insteadloopback.responseTime
- userequire('response-time')
insteadloopback.favicon
- userequire('serve-favicon')
insteadloopback.directory
- userequire('serve-index')
insteadloopback.vhost
- userequire('vhost')
instead
We have also removed loopback.mime
, which was always set to undefined
.
See loopback#2349.
We have removed loopback#errorhandler
middleware, users should use strong-error-handler
directly.
// server/middleware.json
{
// ...
"final:after": {
"strong-error-handler": {}
}
}
// server/middleware.development.json
{
"final:after": {
"strong-error-handler": {
"params": {
"debug": true
}
}
}
See also strong-error-handler's options and the related code change.