You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The scripts in server/boot are executed by the order of file names as of today.
There are a few use cases that require ordering.
A boot script discovers models from a DB and exposes them as REST APIs. It needs to be executed before the api-explorer.
An async script that needs to be executed after the system-level boot scripts. For example, if we add the following JS file into server/boot today, the express middleware chain will be messed up:
abc.js (this ensures the file name is sorted before rest-api.js, explorer.js)
In this case, boot(app, __dirname) returns before the rest-api.js is executed. As a consequence, urlNotFound and errHandler come before the rest handler.
// boot scripts mount components like REST APIboot(app,__dirname);// -- Mount static files here--// All static middleware should be registered at the end, as all requests// passing the static middleware are hitting the file system// Example:// var path = require('path');// app.use(loopback.static(path.resolve(__dirname, '../client')));// Requests that get this far won't be handled// by any middleware. Convert them into a 404 error// that will be handled later down the chain.app.use(loopback.urlNotFound());// The ultimate error handler.app.use(loopback.errorHandler());
Potential solutions:
Formalize the file names as 01_first.js, 02_second.js for the scaffolded JS files
Use phases (preferred)
In addition, we probably should move the urlNotFound/errorHandler middleware code to a boot script too.
An async script that needs to be executed after the system-level boot scripts. For example, if we add the following JS file into server/boot today, the express middleware chain will be messed up.
Good point. This is sort of an edge case problem introduced by #50, right?
Potential solutions:
Use phases (preferred)
Yes please.
In addition, we probably should move the urlNotFound/errorHandler middleware code to a boot script too.
Alternatively we can register them with the appropriate middleware phase at the time and place where the middleware phases are defined.
In October 2018, LoopBack 4.0 GA was released. LoopBack 3 and its supporting modules have entered LTS mode. Per our Long Term Support Policy, this means new features are no longer accepted.
Activity
bajtos commentedon Oct 24, 2014
My $0.02:
This should be fixed in explorer - see strongloop/loopback-component-explorer#22 and strongloop/loopback#686
Good point. This is sort of an edge case problem introduced by #50, right?
Yes please.
Alternatively we can register them with the appropriate middleware phase at the time and place where the middleware phases are defined.
raymondfeng commentedon Oct 24, 2014
Phaseis the magic pain killer 👍bajtos commentedon Nov 2, 2018
In October 2018, LoopBack 4.0 GA was released. LoopBack 3 and its supporting modules have entered LTS mode. Per our Long Term Support Policy, this means new features are no longer accepted.
I am closing this GitHub issue as "wont fix".