-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Spike] Allow extensions to contribute custom convention for environment-specific operational configuration #1464
Comments
Is there any news about this issue? let dbDataSource = new DbDataSource({
name: 'db',
connector: 'mysql',
hostname: process.env.DB_HOST,
port: process.env.DB_PORT,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE
}); but I'm not sure this could be a best practice. |
@Edo78 see the following resources to learn about other options available:
TL;DR: if you are using this.bind('datasources.config.db').to({
name: 'db',
connector: 'mysql',
hostname: process.env.DB_HOST,
port: process.env.DB_PORT,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE
}); |
Cross-posting from #1609
A mock-up app: class MyApp extends RestApplication {
async boot() {
const dbConfig =
// Figure out what config to use. @loopback/boot can provide
// helpers to load config from ENV variables
this.bind('datasources.db$config').to(dbConfig);
// etc.
}
} A mock-up datasource: // default config is used in tests
const defaultConfig = require('./db.datasource.json');
class DbDataSource extends juggler.DataSource {
constructor(
@inject('datasources.db$config')
config: DataSourceOptions = defaultConfig
) {
super(config);
}
} |
I was going to create a new issue before seeing this one. In order not to pollute the codebase with // sample decorator signature
class SampleClass {
@env('privateid')
privateId: string;
@env('appSecret')
appSecret: string;
constructor() {}
} This can be in a separate package too under I am currently working on something similar and I will be glad to raise my first PR if approved. Let me know what you think 💪 cc: @bajtos |
This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the |
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the |
I am trying to use environmental variables to load my datasources configuration but I am running into issues when using some of the CLI tools. Do you guys have any suggestions on how can I solve this? This issue seems to be closed but there isn't an actual solution yet. So, I would like to propose an idea. |
Vote to reopen 😄 |
Reopened 👍 |
So what is the official recommendation to use environment variables in loopback 4? Is this item still pending? |
I agree that we need a recomendation or a path, a search in google shows version 3, but in the last release it isn't any more viable. |
2024 and still no way to use .env for datasource? |
Timeboxed to 2 weeks; don't spend extra time if done earlier
Different platforms use different ways for configuring operational aspects of application in test/dev/production. LB4 should make it easy to write extensions to support these different platforms.
The goal of this spike is to find out and document what's possible today, identify gaps, propose solutions and create a list of follow-up tasks.
Few examples of operational config:
VCAP_SERVICES
env variable in CloudFoundry/IBM Cloud - see [WIP] Spike: todo example on IBM Cloud [DO NOT MERGE] #1574Possibly related: #983 and #1396
The text was updated successfully, but these errors were encountered: