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
LB3 configs are centralized in following 3 file sets with a predefined override precedence
/server/config.(<env>|local.)js(on)
/server/datasources.(<env>|local.)js(on)
/server/middleware.(<env>|local.)js(on)
I created a notification microservice software based on LB3. I provide default configs in (config|datasources|middleware).js(on). Users customize their installations to fit their needs by creating corresponding local config files which are merged with and taking precedence over mine.
To minimize migration effort for my users, I would like to reuse the LB3 config files and preserve override precedence. However, LB4 configs are dispersed into bindings by design. There are no centralized config files and no easy way for config overriding.
With binding alias, it is feasible to centralize configs in LB4. I believe this is a common migration use case. LB4 can and should implement a standardized approach. For starter, following is my code snippet to import ApplicationConfig from files config.(<env>|local.)js(on) preserving override precedence. What's left is to create binding alias for common LB configs such as restApiRoot, host, port etc.
...
import * as _ from 'lodash';
export class MyApplication extends BootMixin(
ServiceMixin(RepositoryMixin(RestApplication)),
) {
constructor(options: ApplicationConfig = {}) {
let configFiles = [
'config.json',
'config.js',
'config.local.json',
'config.local.js',
];
if (process.env.NODE_ENV) {
configFiles = configFiles.concat([
`config.${process.env.NODE_ENV}.json`,
`config.${process.env.NODE_ENV}.js`,
]);
}
for (const configFile of configFiles) {
const f = path.join(__dirname, configFile);
if (fs.existsSync(f)) {
_.mergeWith(options, require(f), (t, s) => {
if (_.isArray(t)) {
return s;
}
});
}
}
super(options);
...
}
...
}
This discussion was converted from issue #6044 on March 11, 2021 13:42.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
LoopBack 3 use case
LB3 configs are centralized in following 3 file sets with a predefined override precedence
I created a notification microservice software based on LB3. I provide default configs in (config|datasources|middleware).js(on). Users customize their installations to fit their needs by creating corresponding local config files which are merged with and taking precedence over mine.
To minimize migration effort for my users, I would like to reuse the LB3 config files and preserve override precedence. However, LB4 configs are dispersed into bindings by design. There are no centralized config files and no easy way for config overriding.
With binding alias, it is feasible to centralize configs in LB4. I believe this is a common migration use case. LB4 can and should implement a standardized approach. For starter, following is my code snippet to import ApplicationConfig from files config.(<env>|local.)js(on) preserving override precedence. What's left is to create binding alias for common LB configs such as restApiRoot, host, port etc.
All reactions